Re: VBA Word 2003 File Close
- From: "Doug Robbins - Word MVP" <dkr@xxxxxxxxxxxxxxxxxx>
- Date: Sat, 2 May 2009 08:37:36 +1000
It would be better to declare a variable as a Document and set that variable to the document that you are opening rather than rely on the active document. So assuming you declared Source as that variable with
Dim Source as Document
and then when you opened the document you used
Set Source = Documents.Open("FileName")
the when finished with that document, use
Source.Close wdDoNotSaveChanges
--
Hope this helps.
Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.
Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
"David Schnelbaker" <DavidSchnelbaker@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message news:10BFBA6E-D5DD-4670-B82B-EA8A483905E4@xxxxxxxxxxxxxxxx
Word 2003,
In a Word 2003 template document I have a macro triggered by a CheckBox
event template that opens up another document, grabs data in that second
document and then is supposed to close that second document.
When I run the macro from the VBA editor it works exactly as designed with
no errors. But when the Macro is triggered as a result of the CheckBox
status change, I get a run-time error 4198 "Command Failed" at the line that
closes the document.
The offending line is just "ActiveDocument.Close (False)". I have put a
MsgBox with the describing the ActiveDocument so I know it is the right doc
that I am trying to close.
Any ideas?
.
- Follow-Ups:
- Re: VBA Word 2003 File Close
- From: David Schnelbaker
- Re: VBA Word 2003 File Close
- References:
- VBA Word 2003 File Close
- From: David Schnelbaker
- VBA Word 2003 File Close
- Prev by Date: Re: Deleting last page
- Next by Date: I cannot open a blank document in word 2000, only opens previously
- Previous by thread: VBA Word 2003 File Close
- Next by thread: Re: VBA Word 2003 File Close
- Index(es):
Relevant Pages
|