Solved

Visio 2013 - executing VBA code after landing in a page

Posted on 2014-03-13
8
694 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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VIsio connector question 2 453
Multiple people using one copy of software 5 46
Problem to line 6 57
Looking for a laptop computer  that match my needs 5 52
Periodically someone asks me whether there’s a way to automatically convert all of the pages in a Visio drawing to PowerPoint slides. There have even been a few times when I’ve wanted to do that myself but I never really had enough incentive to figu…
Meetings to discuss business process can waste time, and often do .  The meeting's dialog can get confusing when participants have different professional perspectives and backgrounds.  A jointly-developed process picture helps wade through the confu…

749 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