View Single Post
 
Old 11-14-2016, 05:32 AM
gmayor's Avatar
gmayor gmayor is offline Windows 10 Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,138
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

Without the documents this cannot be tested, but a few observations are warranted.

Why have you created another variable for strSubFolderNewName?
Code:
strpat = strSubFolderNewName
Use the strSubFolderNewName name you have already defined.

Your FileExists statements are never true because strSubFolderName doesn't end in a folder separator character, so the documents cannot be created. Thus the lines e.g.
Code:
Case fso.FileExists(strpat & "Mail AU.docx")
            Set oDoc = Documents.Add(Template:=strpat & "Mail AU.docx")
            'etc
should probably be
Code:
Case fso.FileExists(strSubFolderNewName & "\" & "Mail AU.docx")
            Set oDoc = Documents.Add(Template:=strSubFolderNewName & "\" & "Mail AU.docx")
            'etc
You have declared and defined some variables 'anexa#' but not used them?
You have created CreateObject("Scripting.FileSystemObject") twice as fso and oFSO. You only need to create it once and use the same object twice.
__________________
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