how to open visio file by Excel VBA

M

moonhk

Hi All

how to open visio file by Excel VBA ?


I try below coding not ok.

Set oApp = CreateObject("Visio.Application")
oApp.Visible = True
MsgBox FN
oApp.Documents.Open FN
 
C

Chip Pearson

The following code works for me with Excel 2007 and Visio 2007.


Sub OpenVisioDoc()
Dim FName As String
Dim VisioApp As Object

On Error Resume Next
Set VisioApp = GetObject(, "Visio.Application")
If VisioApp Is Nothing Then
Set VisioApp = CreateObject("Visio.Application")
If VisioApp Is Nothing Then
MsgBox "Can't connect to Visio"
Exit Sub
End If
End If
On Error GoTo 0
FName = "C:\Path\FileName.vsd"

VisioApp.documents.Open FName '
VisioApp.Visible = True
End Sub
 
M

moonhk

The following code works for me with Excel 2007 and Visio 2007.

Sub OpenVisioDoc()
Dim FName As String
Dim VisioApp As Object

On Error Resume Next
Set VisioApp = GetObject(, "Visio.Application")
If VisioApp Is Nothing Then
Set VisioApp = CreateObject("Visio.Application")
If VisioApp Is Nothing Then
MsgBox "Can't connect to Visio"
Exit Sub
End If
End If
On Error GoTo 0
FName = "C:\Path\FileName.vsd"

VisioApp.documents.Open FName '
VisioApp.Visible = True
End Sub









- Åã¥Ü³Q¤Þ¥Î¤å¦r -

Using below coding works.

'~~ http://support.microsoft.com/kb/309603
Set oApp = CreateObject("Visio.Application")
Set docsObj = oApp.Documents
Set DocObj = docsObj.Open(FN)
' Clear the variable from memory.
Set docsObj = Nothing
Set DocObj = Nothing
Set oApp = Nothing
 

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