View Single Post
 
Old 10-13-2017, 08:34 PM
gmayor's Avatar
gmayor gmayor is offline Windows 10 Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,144
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

Presumably PDF is a pre-existing sub folder of the original folder in which case

Code:
    While Len(strFilename) <> 0
        Set oDoc = Documents.Open(strPath & strFilename)
        strDocName = ActiveDocument.Name 'Use Name not fullname
        intPos = InStrRev(strDocName, ".")
        strDocName = Left(strDocName, intPos - 1)
        'This instruction converts to PDF
        strDocName = strDocName & ".pdf"
        oDoc.SaveAs FileName:=strPath & "PDF\" & strDocName, _
                    FileFormat:=wdFormatPDF 'add the path
        oDoc.Close SaveChanges:=wdDoNotSaveChanges
        strFilename = Dir$()
    Wend
If you want to create the folder then see the Createfolders function at https://www.gmayor.com/useful_vba_functions.htm where you will also find code to ensure the filenames are unique to avoid overwriting duplicated names.
__________________
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