ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Excel VBA to execute Visio VBA (https://www.excelbanter.com/excel-programming/381843-re-excel-vba-execute-visio-vba.html)

Chip Pearson

Excel VBA to execute Visio VBA
 
In VBA in Excel, go to the Tools menu and set a reference to "Visio 11 Type
Library" or whatever version of Visio you have. Then use code like the
following.


Sub AAA()
Dim VIS As Visio.Application
Dim VisDoc As Visio.Document

On Error Resume Next
Set VIS = GetObject(, "Visio.Application")
If VIS Is Nothing Then
Set VIS = CreateObject("Visio.Application")
If VIS Is Nothing Then
MsgBox "Cannot access Visio"
Exit Sub
End If
End If
On Error GoTo 0
VIS.Visible = True
Set VisDoc = VIS.Documents.Add(Filename:="C:\Drawing2.vsd") '<<< CHANGE
VisDoc.ExecuteLine "MacroName" '<<< CHANGE
VisDoc.Close
VIS.Quit
End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)





"Jason V" wrote in message
...
My Excel VBA program opens a visio application. From there I either want
to
run a macro in that Visio file or I want to code it in my excel program.
Any
help? Thanks.
--
Jason V





All times are GMT +1. The time now is 01:33 PM.

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