2016-12-16 63 views
0

編譯錯誤我有一個Excel宏和子(內聲明該變量):如何管理VBA

Dim ACAD As AcadApplication 

而且如果計算機沒有AutoCAD中,我獲得一個編譯錯誤。然後,我想要做的是爲了顯示一個消息給用戶來管理這個錯誤,如:

MsgBox "You have to install AutoCAD 2013 or later", vbCritical, "APPLICATION ERROR" 

我用Google搜索了半天,沒有回答。也許我沒有正確使用關鍵詞。

任何人都可以幫助我嗎?

+0

什麼錯誤捕獲你此刻在你的代碼? –

回答

1

您可以使用創建的對象,而不是添加引用,並用它聲明暗淡 下面是和示例

On Error Goto AppNotfound 
    Set Web = CreateObject("InternetExplorer.Application") 
    On Error Goto 0 
    'Your Code here 
    Exit Sub 
    AppNotfound: 
Msgbox("You have to install AutoCAD 2013 or later") 

Exit Sub 
End Sub