Closing Unused Windows

J

jdfunk

I've created clickable icons with a macro that will allow me to jump from one
file to another. I'd like to add something into the macro that would close
the old file once I move on to the next one. Any suggestions? Here's the very
simple macro I have right now:

Sub Overview()
Application.Documents.OpenEx "\\Ohio EDS\Cleveland FMS\Ohio EDS Ver 2\Ohio
EDS\Cleveland EDS Overview ver3.vsd", visOpenRW

End Sub

I tried the following and couldn't get it to work:

Sub Overview()
Application.Documents.OpenEx "\\Usclb1fp001\data\DMJM\ODOT Projects\Ohio
EDS\Cleveland FMS\Ohio EDS Ver 2\Ohio EDS\Cleveland EDS Overview ver3.vsd",
visOpenRW

End Sub

Private Sub Document_BeforeDocumentClose(ByVal doc As IVDocument)
Application.Documents.OpenEx "\\Usclb1fp001\data\DMJM\ODOT Projects\Ohio
EDS\Cleveland FMS\Ohio EDS Ver 2\Ohio EDS\Cleveland EDS Overview ver3.vsd",
visOpenRW

End Sub

Any help would be appreciated.
 
C

Chris Roth [Visio MVP]

Hi JD,

Which part of your macro isn't working, the opening of the new file or
the closing of the old file?

I'm also wondering if you are perhaps closing the document that contains
the VBA code, which might be cutting off your functionality prematurely.

I think your program flow should go something like this:

1. Get the calling document (from where the shape was clicked).
Visio.ActiveDocument should probably work in most cases.
2. Get the path for the target doc
3. Open the target doc
4. Close the original doc

Also, Visio shapes can hyperlink to other documents (without using
code). This won't close other documents, but it might simplify your
solution to an extent that is worth consideration?

--
Hope this helps,

Chris Roth
Visio MVP


Visio Guy: Smart Graphics for Visual People

Articles: http://www.visguy.com
Shapes: http://www.visguy.com/shapes
Dev: http://www.visguy.com/category/development/
Forum: http://www.viguy.com/vgforum
 
J

jdfunk

Chris,

Thanks for the suggestions. For the Macro I tried using originally I can't
get it to close the original file or open the one I'm trying to switch to. I
think you were correct when you said it won't let me close out the file I've
got the code in.

I'd tried your other suggestion before and I couldn't get any results from
it either. Here's the code I used:

Sub Return_To_Overview()

Application.Documents.OpenEx "\\Ohio EDS\Cleveland FMS\Ohio EDS Ver
2\Ohio EDS\Cleveland EDS Overview ver3.vsd", visOpenRW

ActiveDocument.Close

End Sub

When I run that it seems to treat the new file I'm trying to open as the
ActiveDocument and closes it immediately after opening it, taking me back to
the original file.


Oh, and I did try the hyperlinking but I wasn't a fan of the fact you have
to right click to follow the link unless you're in full-screen mode.

Cheers,
JD
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top