Solved

Visio 2013 - executing VBA code after landing in a page

Posted on 2014-03-13
8
698 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Enroll in June's Course of the Month

June’s Course of the Month is now available! Experts Exchange’s Premium Members, Team Accounts, and Qualified Experts have access to a complimentary course each month as part of their membership—an extra way to sharpen your skills and increase training.

Question has a verified solution.

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

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…
Book Review: Using Microsoft Visio 2010 by Chris Roth   Disclaimer: The author of Using Visio 2010 is a friend and fellow Visio MVP. Whether you’re new to Visio or are upgrading to Visio 2010 from a previous version, you will find a lot to like…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …

705 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