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.applic ation")
End If
Try
VisioApplication.Documents .Open(Visi oPathName)
VisioPages = VisioApplication.ActiveDoc ument.Page s
VisioPage = VisioPages.Item(1)
VisioShapes = VisioPage.Shapes
Catch ex As Exception
MsgBox(ex.Message)
End
End Try
If IsNothing(VisioApplication
VisioApplication = CreateObject("visio.applic
End If
Try
VisioApplication.Documents
VisioPages = VisioApplication.ActiveDoc
VisioPage = VisioPages.Item(1)
VisioShapes = VisioPage.Shapes
Catch ex As Exception
MsgBox(ex.Message)
End
End Try
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I found the problem.
I needed to use:
If Err().Number = 0 Then
I needed to use:
If Err().Number = 0 Then
ASKER
If Err = 0
I get this message
Operator '=' is not defined for types 'Microsoft.VisualBasic.Err