Avatar of mmtcunningham1
mmtcunningham1 asked on

If application is already open, how do I close it and start a new one????

In my program, I want to open a visio file but if it is already open, I want to close it and open a new version of the file.  Here's the code that I currently have.  I run into problems if the application is already open.

If IsNothing(VisioApplication) Then
            VisioApplication = CreateObject("visio.application")
        End If


        Try
            VisioApplication.Documents.Open(VisioPathName)
            VisioPages = VisioApplication.ActiveDocument.Pages
            VisioPage = VisioPages.Item(1)
            VisioShapes = VisioPage.Shapes

        Catch ex As Exception
            MsgBox(ex.Message)
            End
        End Try
Visual Basic ClassicMicrosoft VisioProgramming

Avatar of undefined
Last Comment
mmtcunningham1

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Patrick Matthews

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
ASKER
mmtcunningham1

I'm having a problem with the line
If Err = 0
I get this message
Operator '=' is not defined for types 'Microsoft.VisualBasic.ErrObject' and 'Integer'.      
ASKER
mmtcunningham1

I found the problem.
I needed to use:
If Err().Number = 0 Then
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck