使用Excel 2016打开Visio-File不起作用

时间:2016-02-29 14:56:43

标签: excel vba visio

我有一个小的Excel宏打开一个visio文件。使用Excel 2010一切正常。现在我已经安装了Office 2016并尝试了相同的excel-macro,它将无法正常工作。

没有例外,但我看到我的变量“VisioDoc”为空。

你有什么想法可以解决问题吗?

Sub cmdChooseFile_Click()

'...do something

Set VisioDoc = openDocument(filepath)
   If VisioDoc Is Nothing Then
      MsgBox "boom, didn't work!", vbExclamation
      Exit Sub
   End If
End Sub

Private Function openDocument(docPath As String) As Visio.Document
    visioOpened = True
    Application.StatusBar = "Lade Visiodokument..."
    On Error Resume Next

    Set VisioApp = GetObject(, "Visio.Application")

    If VisioApp Is Nothing Then
        Set VisioApp = CreateObject("Visio.Application")
        VisioApp.Visible = False
        visioOpened = False
    End If

    Set openDocument = VisioApp.Documents.Open(docPath)
    Application.StatusBar = False
End Function

0 个答案:

没有答案