View Single Post
  #7   Report Post  
Cindy M -WordMVP-
 
Posts: n/a
Default

Hi Vic,

Thank you very much for the answer, I now have it resolved. I had already
done all of the things that you mentioned except the changing
"ActiveDocument" to WordDoc and I was still getting the error. After this
final change it now works correctly.

I use this same code in VBA and I've never had this problem. Why would that
be?

I'm not certain, but it probably has something to do with how object variables
(don't) go out of scope. Take a look again at the code you posted: you tell
VB6 to use ActiveDocument, but you don't tell it where to find ActiveDocument,
so VB6 has to guess (it should be WordApp.ActiveDocument). And in order to
make the association, it probably has to build another connection to the Word
application in the background - one to which you have no access and therefore
can't clear.

When you use ActiveDocument in Word you don't have to qualify it with the
application object. Word *knows* you mean it to work locally.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :-)