在 Visio 中选择活动页面
Choose active page in Visio
已编辑:我并没有这么说。我正在尝试打开 Visio(正在运行),然后在我选择的文档中打开一个页面。谢谢
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
但这是试图重命名活动页面的代码。我希望它 select 引号中的页面名称。
尝试:
VsApp.ActiveWindow.Page = vsPage
如果还是不行,试试:
VsApp.ActiveWindow.Page = VsApp.Documents.Open(FName).Pages(vsPage)
已编辑:我并没有这么说。我正在尝试打开 Visio(正在运行),然后在我选择的文档中打开一个页面。谢谢
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
但这是试图重命名活动页面的代码。我希望它 select 引号中的页面名称。
尝试:
VsApp.ActiveWindow.Page = vsPage
如果还是不行,试试:
VsApp.ActiveWindow.Page = VsApp.Documents.Open(FName).Pages(vsPage)