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, ...)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…