Solved

Visio 2013 - executing VBA code after landing in a page

Posted on 2014-03-13
8
677 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
 
LVL 11

Expert Comment

by:Visio_Guy
ID: 39934467
Haha!
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

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 lists. We’ll explore containers and callouts in separate articles. Prior to reading th…
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 I’ll describe a mashup of containers and lists that meet a real-world need. Prior to reading this ar…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

744 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now