Author Topic: Position of the drawing page by VBA code  (Read 3969 times)

0 Members and 1 Guest are viewing this topic.

kgurr

  • Newbie
  • *
  • Posts: 3
Position of the drawing page by VBA code
« on: July 23, 2021, 12:10:36 AM »
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

  • Hero Member
  • *****
  • Posts: 1350
    • ShapeSheet™ Knowledge Base
Re: Position of the drawing page by VBA code
« Reply #1 on: July 23, 2021, 02:21:01 AM »
This 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

  • Hero Member
  • *****
  • Posts: 2744
Re: Position of the drawing page by VBA code
« Reply #2 on: July 23, 2021, 04:15:00 AM »
Iterate over the pages of the document
  ActiveWindow.Page = tempPage
  ActiveWindow.ViewFit = visFitPage
Yacine

wapperdude

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4050
  • Ideas Visio-lized into solutions
« Last Edit: July 23, 2021, 02:05:24 PM by wapperdude »
Visio 2019 Pro

Visio Guy

  • Administrator
  • Hero Member
  • *****
  • Posts: 1725
  • Smart Graphics for Visual People...n' Stuff
    • Visio Guy
Re: Position of the drawing page by VBA code
« Reply #4 on: July 25, 2021, 05:47:58 PM »
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

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4050
  • Ideas Visio-lized into solutions
Re: Position of the drawing page by VBA code
« Reply #5 on: July 25, 2021, 06:21:43 PM »
@Visio Guy:  Ah choo!  I remember those.  Found them in a very dusty corner.  😱
Visio 2019 Pro

kgurr

  • Newbie
  • *
  • Posts: 3
Re: Position of the drawing page by VBA code
« Reply #6 on: July 26, 2021, 12:58:37 AM »
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

  • Hero Member
  • *****
  • Posts: 1350
    • ShapeSheet™ Knowledge Base
Re: Position of the drawing page by VBA code
« Reply #7 on: July 26, 2021, 02:29:12 AM »
Window.GetViewRect
I try use this method in my code
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
« Last Edit: July 26, 2021, 02:33:53 AM by Surrogate »

kgurr

  • Newbie
  • *
  • Posts: 3
Position of the drawing page by VBA code - SOLVED
« Reply #8 on: July 27, 2021, 01:29:56 AM »
Hello Surrogate,
this works perfectly.
 :)
Thank you for the support!