问题
I have a button on a form in my database that i would like to open a user guide on click. The user guide I have put to gether is in visio but i can't seem to find a way to open it using the macro builder. Is this something i would need to do using VBA? If so any suggestions on how the code should look?
回答1:
I think something like the following may work, I have manipulated this to fit visio though, so hopefully it works.
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
You may need to go in to the VB editor, click Tools
> References
and then mark Microsoft Visio library as checked.
来源:https://stackoverflow.com/questions/36495483/open-visio-drawing-using-a-macro-in-access-2010