Error 462 in VBA : remote server machine not found

本秂侑毒 提交于 2019-12-06 02:40:59

Does it break when you launch it twice ?

Cause

Visual Basic has established a reference to Excel because of a line of code that calls an Excel object, method, or property without qualifying the element with an Excel object variable. Visual Basic does not release this reference until you end the program. This errant reference interferes with automation code when the code is run more than one time.

Resolution

To resolve this problem, modify the code so each call to an Excel object, method, or property is qualified with the appropriate object variable.

Source

Have a look here : http://support.microsoft.com/default.aspx?kbid=178510


You could also have a look here : http://www.tek-tips.com/viewthread.cfm?qid=756598

The author of the post was getting the error because he was not using the Access object to open and close the database.


And finally :

  • you should avoid using the with block with a Word Application object
  • you should free your variables (Set ... As Nothing, wrdApp.Close, ...)

or you can try this shorter version:

Function abc() As String
    doc = "C:\Documents and Settings\Administrator\My Documents\Downloads\fwfiles\webs.doc"
    Set objDoc = GetObject(doc, "Word.Application")
    abc = doc.Range.Text
    objDoc.Close
    objDoc = Nothing
End
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!