Link to home
Start Free TrialLog in
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
ASKER CERTIFIED SOLUTION
Avatar of Patrick Matthews
Patrick Matthews
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mmtcunningham1
mmtcunningham1

ASKER

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'.      
I found the problem.
I needed to use:
If Err().Number = 0 Then