error 4198 on mydoc.close

J

Jon LeBaugh

HELP!

I am creating a new document based off a template
inserting data into it (from a form with it stored in forfields to this form
with bookmarks), printing it, then (trying to) close it. Code follows....

Set newbitdoc = Word.Documents.Add(mytemplatepathandname, , , False)
'code to put info into doc here
newbitdoc.PrintOut Background:=False
newbitdoc.Close wdDoNotSaveChanges 'errors here everytime

When it errors (error4198 -- command fails). I can debug it and run it from
there and it works perfectly. I can also run it from the VB Editor and it
works just fine there, but when I run it initiated from inside my first
document (entering a formfield triggers it) it crashes at the close
statement. I have tried it with the .printout statement commented out to see
if it was a problem with the document still printing with the same result. I
tried putting some doevents commands before the close statement, did not
affect it. The data I am inserting is pulled from formfields on the first
document and placed in bookmards on the document being created/printed/closed.

THANKS!!!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top