Thread: [Solved] Save as both pdf and docx
View Single Post
 
Old 02-25-2015, 02:54 AM
gmayor's Avatar
gmayor gmayor is offline Windows 7 64bit Office 2010 32bit
Expert
 
Join Date: Aug 2014
Posts: 4,142
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

There will be no warning if you save with VBA (at least not in a PC environment). I am not sure if this will translate to the Mac.

Code:
Sub SaveAsDocXandPDF()
Dim strPath As String
    On Error GoTo err_Handler
    ActiveDocument.Save
    strPath = Left(ActiveDocument.FullName, InStrRev(ActiveDocument.FullName, ".") - 1) & ".pdf"
    ActiveDocument.SaveAs2 Filename:=strPath, FileFormat:=wdFormatPDF, AddToRecentFiles:=False
lbl_Exit:
    Exit Sub
err_Handler:
    MsgBox "Document not saved"
    Resume lbl_Exit
End Sub
__________________
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