问题
Edited: I didn't phrase this very will.. I am trying to open Visio (working) and then open a page in the document of my choosing. Thanks
Dim FName As String
Dim VsApp As Object
On Error Resume Next
Set VsApp = GetObject(, "Visio.Application")
If VsApp Is Nothing Then
Set VsApp = CreateObject("Visio.Application")
If VsApp Is Nothing Then
MsgBox "Can't connect to Visio"
Exit Sub
End If
End If
On Error GoTo 0
FName = "C:\myfile.vsd"
If Not Intersect(Target, Range("c2")) Is Nothing Then
VsApp.Documents.Open FName
VsAppPage = "mypage"
Cancel = True
ElseIf Not Intersect(Target, Range("c4")) Is Nothing Then
VsApp.Documents.Open FName
vsPage = "mypage2"
VsApp.ActivePage = vsPage
Cancel = True
End if
But this is code it trying to rename the active page. I would like it to select the page name in quotes.
回答1:
Try:
VsApp.ActiveWindow.Page = vsPage
If that doesn't work, try:
VsApp.ActiveWindow.Page = VsApp.Documents.Open(FName).Pages(vsPage)
来源:https://stackoverflow.com/questions/30646937/choose-active-page-in-visio