View Single Post
 
Old 09-08-2018, 11:04 PM
gmayor's Avatar
gmayor gmayor is offline Windows 10 Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,137
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

Quote:
Originally Posted by raywood View Post
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
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote