Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

source.close not working,

Status
Not open for further replies.

simon1tan

MIS
Joined
Aug 3, 2011
Messages
7
Location
US
Word 2010
Hi, in my VBA I'm opening a external word doc to get some text:

Set sourcedoc = Application.Documents.Open(sFile)

Once I get the text, I try to close this document:
oFFld("Text2").Result = sourcedoc.Range
sourcedoc.Close

I'm getting an error message "Runtime error 4198. Command failed". This seems to work pretty well in Word 2003. When I click on debug and continue to run it, the document closes without error. Seems like I'm trying to close it too fast or something. Any ideas?
 


hi,
I'm getting an error message "Runtime error 4198. Command failed".
On what statement?

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
What about thid ?
oFFld("Text2").Result = sourcedoc.Range.Iext
DoEvents
sourcedoc.Close


Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
haha. error occurs on the sourcedoc.Close statement. I kinda of have it figured out by opening the document visible=false and readonly=true. Not even using sourcedoc.close anymore. Hopefully it doesn't cause any issues down the road.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top