Solved

Visio 2013 - executing VBA code after landing in a page

Posted on 2014-03-13
8
687 Views
Last Modified: 2014-03-20
I have a 30 page Visio file and each time I navigate to a page 1, 3, 7, etc. I would like that page to change its view into FIT TO WINDOW.

How can I get this done?
0
Comment
Question by:brothertruffle880
  • 3
  • 3
  • 2
8 Comments
 
LVL 11

Assisted Solution

by:Visio_Guy
Visio_Guy earned 250 total points
ID: 39928129
Well, if you are using hyperlinks on shapes, you can set a target zoom level:
Hyperlink Zoom Level
0
 
LVL 30

Accepted Solution

by:
Scott Helmers earned 250 total points
ID: 39929117
The hyperlink approach Visio_Guy suggested above works very nicely. But if you also want to change the zoom setting when someone manually changes pages, a few lines of code will do the job.

Dim WithEvents Win1 As Visio.Window

Private Sub Document_DocumentOpened(ByVal doc As IVDocument)

    Set Win1 = ActiveWindow

End Sub

Private Sub Win1_WindowTurnedToPage(ByVal Window As IVWindow)

    Win1.Zoom = -1

End Sub

Open in new window

To avoid having the repeatedly open and close the document to test your code, see this article by Visio_Guy.
0
 

Author Comment

by:brothertruffle880
ID: 39934370
Both solutions are equally useful, terse and brilliant.  
In a stupid design decision, EE only allows one BEST solution --which in this case is profoundly unjust.
0
Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

 
LVL 11

Expert Comment

by:Visio_Guy
ID: 39934467
Haha!
0
 

Author Comment

by:brothertruffle880
ID: 39934480
Scot:
Where do I place the code?
I put it in THIS DOCUMENT and nothing happened.
I put it in MODULE1 and the DIM statement appeared in Red.

Dim WithEvents Win1 As Visio.Window

Private Sub Document_DocumentOpened(ByVal doc As IVDocument)

    Set Win1 = ActiveWindow

End Sub

Private Sub Win1_WindowTurnedToPage(ByVal Window As IVWindow)

    Win1.Zoom = -1

End Sub 

Open in new window

0
 
LVL 30

Expert Comment

by:Scott Helmers
ID: 39935634
Place the code in ThisDocument. Close the document and then open it again -- that will execute Document_DocumentOpened, which activates the ability to trap the turned-to-page event.

At this point, the code will be running but it won't look like it's doing anything unless you have pages that are zoomed in or out. So -- zoom way in or out on a page, change to another page and then change back to the first page -- it will be back to full page view.
0
 

Author Comment

by:brothertruffle880
ID: 39942302
Put code in ThisDocument
0
 
LVL 30

Expert Comment

by:Scott Helmers
ID: 39942391
The attached file includes the code pasted from above.
Zoom-to-full-page-on-page-turn.vsd
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
visio 2013 editing 3d cube stencil 3 1,056
how do i get low resolution file from visio 4 111
MS 365 & Visio 4 76
Best free Visio Editor? 2 162
The Question Several times in recent years, someone has posted a question at EE asking whether they could display the Windows directory structure – folders and subfolders – using Visio. When one person specifically asked about displaying directory …
The ability to add structure to Visio diagrams using containers, lists and callouts is one of my favorite features in Visio 2010. In this article we’ll examine containers. We’ll explore lists (http://www.experts-exchange.com/Microsoft/Applications/M…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question