Quote:
Originally Posted by macropod
I see that you have 'Set wrdApp = Nothing', but I don't see where you've terminated the wrdApp session (i.e. wrdApp.Quit). Not having that means you'll have an orphaned Word session floating around.
Hint: Since it seems you want your Word session to be running for multiple documents, you should start the Session independently of all the looping that opens the documents, then kill it once all the processing has been done. See, for example: https://www.msofficeforums.com/excel...readsheet.html
|
Macropod, I'm not sure if I want my word session to run for multiple documents necessarily. This is what is happening: If I run it, it applies the styles ok. I then manually either close or save the generated word doc. That is fine.
However, if I run the code a second time, just to see if I get the same results, that's when I get
Run-Time Error '462': The remote server machine does not exist or is unavailable.
When I get this error, this part of the line is highlighted in yellow:
If bBulletA = False Then
Call AddBulletStyle("BulletA", ChrW(61623), InchesToPoints(0), InchesToPoints(0.5), True)
I also suspected another instance of Word running, but I am a novice in Word VBA and wasn't sure how to handle it. Anyway, I placed "wrdApp.Quit" right before setting wrdDoc and WrdApp to Nothing in my code but the error persisted.
Also, when you say "start the Session independently of all the looping that opens the documents, then kill it once all the processing has been done," I don't think I start wrdApp or wrdDoc in a loop in my code above, so I am unsure what to do. So sorry to bother you this much but I am not that experienced in word vba.
I have an idea ... how about a code to check and close any open/orphaned Word session(s) before a new one is open each time the code runs?
Thanks!
Jay