Position of the drawing page by VBA code

Started by kgurr, July 23, 2021, 05:10:36 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

kgurr

Hello,
I have a question about the position of the drawing page.

When I save a Visio file and open it again, Visio will reopen the drawing page exactly with the position in the Visio window as I saved the file.

This means Visio remembers / saves the horizontal and vertical distance of the drawing to the window in the file... anywhere.

So far I have not been able to find these positions in Visio's object model!?

I would like to define these positions via VBA and am therefore looking for a way to do this... looking for the working VBA line.

I would be very grateful for a hint.

Surrogate

Quote from: kgurr on July 23, 2021, 05:10:36 AMThis means Visio remembers / saves the horizontal and vertical distance of the drawing to the window in the file... anywhere.
what you mean as anywhere?
Did you check properties of ActiveWindow object?

Yacine

Iterate over the pages of the document
  ActiveWindow.Page = tempPage
  ActiveWindow.ViewFit = visFitPage
Yacine

wapperdude

Visio 2019 Pro

Visio Guy

You can't depend on the size of the "next" Visio window that will see your document's page, but you can examine and control what is seen in the active window via:

Window.GetViewRect
Window.SetViewRect
For articles, tips and free content, see the Visio Guy Website at http://www.visguy.com
Get my Visio Book! Using Microsoft Visio 2010

wapperdude

@Visio Guy:  Ah choo!  I remember those.  Found them in a very dusty corner.  😱
Visio 2019 Pro

kgurr

Hello,
thank you for your response  :)

"annywhere" means that the setting is obviously stored in the file (vsdx file), but I don't know where and how to access.

The second thing is, that this setting has nothing to do with the zoom factor. As shown in the screen shot, it is about the distance of the drawing sheet to the Visio window.

Therefore the commands
* visFitPage
* window.zoom
* window.windowstate
do not help... Nevertheless a mercy for the hint!


"SetViewRect" seems to be the right track, but I have not yet managed to find the working command...
There is no complete example for the command on the Microsoft command page.... at the moment I get an exception error.
I know that the windows variable needs to be of type "visDrawing" ... but I did not have the time to figure out how to work with this... yet.

Will test it further with SetViewRect... when I got the solution, I will get back.

Surrogate

#7
Quote from: Visio Guy on July 25, 2021, 10:47:58 PMWindow.GetViewRect
I try use this method in my code
Public Sub SetWindowRect_Example()
Dim vsoApplication As Visio.Application
Dim vsoWindow As Visio.Window
Dim pinLeft As Double, pinTop As Double, pinWidth As Double, pinHeight As Double
Set vsoApplication = Visio.Application
Set vsoWindow = ActiveWindow
vsoWindow.GetViewRect pinLeft, pinTop, pinWidth, pinHeight
Debug.Print pinLeft, pinTop, pinWidth, pinHeight
End Sub

kgurr

Hello Surrogate,
this works perfectly.
:)
Thank you for the support!