1
我正在使用VBA創建單詞的實例,目前通過添加對庫的引用,但這會導致問題,因爲存在一些沒有單詞的機器。創建對象以便實時處理字(VBA)
這會導致這些機器啓動時立即出現運行時錯誤。無法捕捉到這個錯誤。
不過,我試圖通過這樣的
Dim oWshShell As WshShell
Set oWshShell = New WshShell
' *** TEST REGESTRY
Dim tmp As String
tmp = oWshShell.RegRead("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Office\15.0\Word\Options\PROGRAMDIR")
Debug.Print tmp
tmp = tmp + "winword.exe"
Dim oWord As Object
Set oWord = Shell(tmp)
到動態創建的VBA的對象,但我的問題是,oWord不是Word.Application的對象。那麼如何處理呢?
很高興能獲得像Word.Application一樣的所有功能。
請參閱http://stackoverflow.com/questions/9491314/preventing-excel-vba-compile-errors-due-to-users-having-an-older-version-of-ms-o –
或http:///stackoverflow.com/a/41855913/4628637 – R3uK