J
Joe
The desired goal is to convert a WordPefect file to Word and then run a mail merge
to create a new labels document. Ultimately I want to end up with just two documents,
label.wpd and label.doc.
The code I have works most of the time. Occasionally however, it runs into a problem
saving the label file with the name of the data source. The message being that you can’t
save a file with the name of an open file. The data source file is closed when this occurs
but apparently not released from memory.
Is there a better way I can go about this and to make sure the data source file is
completely released? Any help would be greatly appreciated.
Thanks
Joe
The process I’m using is as follows:
Convert all .wpd files to .doc
For each .doc file – create a table and run a mail merge
Document.Open . FoundFiles(i)
File 1 Opens (Becomes the data source)
Create a table to be used as the data source.
Will refer to the current file name (myName) for data source
myName = ActiveDocument.FullName
File 1 Closes
ActiveDocument.Close savechanges:=wdSaveChanges
File 2 Opens (the main document)
Create main document
Documents.Add DocumentType:=wdNewBlankDocument
Use myName as the data source
File 3 Opens (the merge to new doc label file)
With ActiveDocument.MailMerge
.Destination = wdSendToNewDocument
File 2 Activated
Activates main document
ActiveDocument.ActiveWindow.Previous.Activate
File 2 Closes
Close main document without saving changes
ActiveDocument.Close wdDoNotSaveChanges
File 3 Active
Saves the labels file with name of data source (myName)
ActiveDocument.SaveAs FileName:=myName
File 3 Closes
Closes labels file
ActiveDocument.Close
to create a new labels document. Ultimately I want to end up with just two documents,
label.wpd and label.doc.
The code I have works most of the time. Occasionally however, it runs into a problem
saving the label file with the name of the data source. The message being that you can’t
save a file with the name of an open file. The data source file is closed when this occurs
but apparently not released from memory.
Is there a better way I can go about this and to make sure the data source file is
completely released? Any help would be greatly appreciated.
Thanks
Joe
The process I’m using is as follows:
Convert all .wpd files to .doc
For each .doc file – create a table and run a mail merge
Document.Open . FoundFiles(i)
File 1 Opens (Becomes the data source)
Create a table to be used as the data source.
Will refer to the current file name (myName) for data source
myName = ActiveDocument.FullName
File 1 Closes
ActiveDocument.Close savechanges:=wdSaveChanges
File 2 Opens (the main document)
Create main document
Documents.Add DocumentType:=wdNewBlankDocument
Use myName as the data source
File 3 Opens (the merge to new doc label file)
With ActiveDocument.MailMerge
.Destination = wdSendToNewDocument
File 2 Activated
Activates main document
ActiveDocument.ActiveWindow.Previous.Activate
File 2 Closes
Close main document without saving changes
ActiveDocument.Close wdDoNotSaveChanges
File 3 Active
Saves the labels file with name of data source (myName)
ActiveDocument.SaveAs FileName:=myName
File 3 Closes
Closes labels file
ActiveDocument.Close