Quote:
Originally Posted by raywood
gmayor --
One remaining issue: in two tests, for the last .pa-delimited document, I get only a blank page. In one, for instance, there are eight pieces of correspondence ending with .pa; each of the first seven get copied into separate .docx files; there is an eighth .docx file, but it is empty; the eighth letter ending with .pa does not get copied into it.
Just in the spirit of trying to learn a bit from this, maybe the counter is incrementing at the wrong time?
|
The blank page is caused by the fact that you have .pa at the end.
That being the case remove the line to save the document before it is closed
Code:
'oDoc.SaveAs2 strDocName
oDoc.Close wdDoNotSaveChanges
Incidentally this also demonstrated another issue related to that blank page in that there was a missing line in the original code that would have correctly named the last document. This would still have given you a blank page, (the page after the last .pa) but the last true page would have been correct also.
Code:
End With
strDocName = strPath & strName & _
LTrim$(Str$(Counter)) & ".docx"
oDoc.SaveAs2 strDocName
oDoc.Close wdDoNotSaveChanges
Documents.Open strOriginalName