C
CPutnam
Hi, all. I've created a macro that merges a few documents and then combines
some of the text from one into another and saves that as a new document with
a new name. Then I want to close all the documents except the new one.
Here's the code that I'm using:
For Each Document In Documents
If Document.Name <> "c:\download\ProjAbstractMergeFiles\" &
strDocName & ".doc" Then
Document.Activate
ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges
End If
Next Document
(Where "c:\download\ProjAbstractMergeFiles\" & strDocName & ".doc" is the
name of the new document (the user supplied strDocName). Referring to the
document this way works when creating the document and when activating it.)
However, the result of this code is that all open documents are closed!
When I step through my macro code, it looks like it's going through the code
correctly and NOT activating the document I want to keep open but then POOF!
it's closed.
(I'm using Word97 to do this macro but that newsgroup didn't look active at
all. Don't know if this matters but I have attached the macro directly to
the document because I need to distribute the document to a lot of users,
some of whom will be using Word 2002.)
Thanks in advance for any ideas you can give to me. Carol.
some of the text from one into another and saves that as a new document with
a new name. Then I want to close all the documents except the new one.
Here's the code that I'm using:
For Each Document In Documents
If Document.Name <> "c:\download\ProjAbstractMergeFiles\" &
strDocName & ".doc" Then
Document.Activate
ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges
End If
Next Document
(Where "c:\download\ProjAbstractMergeFiles\" & strDocName & ".doc" is the
name of the new document (the user supplied strDocName). Referring to the
document this way works when creating the document and when activating it.)
However, the result of this code is that all open documents are closed!
When I step through my macro code, it looks like it's going through the code
correctly and NOT activating the document I want to keep open but then POOF!
it's closed.
(I'm using Word97 to do this macro but that newsgroup didn't look active at
all. Don't know if this matters but I have attached the macro directly to
the document because I need to distribute the document to a lot of users,
some of whom will be using Word 2002.)
Thanks in advance for any ideas you can give to me. Carol.