Problems Zooming to Selection using BoundingBox

Started by Yacine, May 25, 2013, 09:45:58 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Yacine

Hi guys,
I'm trying desperately in V2007 to zoom properly on the selection on the active window.
... with no avail. The center of the window is always too low and too far right.
I tried using correcting factors, but could not see a scheme in the incorrect panning.
I played of course with the option flags, but gave up at last.
Here's MS' description page of the function: http://msdn.microsoft.com/en-us/library/office/ff766528.aspx

The reported problem (http://support.microsoft.com/kb/2025901) does not apply to my drawing, as I have no groups.




        Dim panMode As Integer
        Dim fPanX As Double, fPanY As Double
        Dim fZoom As Double
'            panMode = visBBoxUprightWH
            panMode = visBBoxUprightText
'            panMode = visBBoxExtents
'            panMode = visBBoxDrawingCoords
            fZoom = 2
            fPanX = 1
            fPanY = 1
        ActiveWindow.Selection.BoundingBox panMode, pLeft, pBottom, pRight, pTop
        ActiveWindow.SetViewRect pLeft * fPanX, pTop * fPanY, (pRight - pLeft) * fZoom, (pTop - pBottom) * fZoom


I hope that one of you out there, has a solution for my problem.
Cheers, Y.
Yacine

AndyW

#1
Are you falling foul of Visio adjusting the zoom level ?

ThisDocument.ZoomBehavior = visZoomVisioExact
Live life with an open mind

Visio Guy

Oooh, Andy, nice one. I've never seen that before!
For articles, tips and free content, see the Visio Guy Website at http://www.visguy.com
Get my Visio Book! Using Microsoft Visio 2010

Yacine

#3
Who modified my #?%#0!~ Title? I almost overlooked the answers to my post?  ;D
Well, it was a little bit too dramatic. Critics accepted.

@ Andy, worked perfectly!!!!! (are 5 exclamation marks enough for an answer that Google could not deliver?). Thank you very much.

@Altzheimer ... I mean Chris,
QuoteI've never seen that before!
Actually you did! Here: http://visguy.com/vgforum/index.php?topic=317.0

@ anyone else, looking for a solution to zoom perfectly on the selection:
Sub zoomOnSelection()
    Dim t As Double, b As Double, l As Double, r As Double
    Dim zoomFaktor As Double
   
    ThisDocument.ZoomBehavior = visZoomVisioExact 'You'd place this statement in a more central place for elegance sake

    activewindow.Selection.BoundingBox visBBoxUprightWH, l, b, r, t
        zoomFaktor = 1.1 ' to get bigger boundaries around the selection
        l = l / zoomFaktor ' You might also use addition and substraction, if page size matters (which I suspect).
        b = b / zoomFaktor
        r = r * zoomFaktor
        t = t * zoomFaktor
    activewindow.SetViewRect l, t, (r - l), (t - b)
End Sub

Yacine

AndyW

Live life with an open mind

Visio Guy

You guys are great. This forum really needs [Like] buttons for the posts...
For articles, tips and free content, see the Visio Guy Website at http://www.visguy.com
Get my Visio Book! Using Microsoft Visio 2010

Paul Herber

Quote from: Visio Guy on May 29, 2013, 09:45:56 AM
You guys are great. This forum really needs [Like] buttons for the posts...
[Like]

Electronic and Electrical engineering, business and software stencils for Visio -

https://www.paulherber.co.uk/

Yacine

#7
I'd take 4 stars of 5 for my answer. Give 5 to Andy, please!
http://custom.simplemachines.org/mods/index.php?mod=2234
I just picked the very first, that did not mention Facebook or twitter. You might find more.
Yacine