ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   how to open visio file by Excel VBA (https://www.excelbanter.com/excel-programming/414970-how-open-visio-file-excel-vba.html)

moonhk[_2_]

how to open visio file by Excel VBA
 
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

Tim Williams

how to open visio file by Excel VBA
 
Try google first....

http://support.microsoft.com/kb/309603

Tim

"moonhk" wrote in message
...
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




Chip Pearson

how to open visio file by Excel VBA
 
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



"moonhk" wrote in message
...
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



moonhk[_2_]

how to open visio file by Excel VBA
 
On 8月1日, 下午9時48分, "Chip Pearson" wrote:
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

"moonhk" wrote in message

...



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- 隱藏被引用文字 -


- 顯示被引用文字 -


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


All times are GMT +1. The time now is 03:00 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com