Hi, I just got some great help on being able to save my Excel File as a PDF.
But now, if the file name already exists where the pdf is being saved, I would like a warning message box to come up before it saves asking "File already exists, overwrite?" Yes button and No button.
But now, if the file name already exists where the pdf is being saved, I would like a warning message box to come up before it saves asking "File already exists, overwrite?" Yes button and No button.
- If Yes, the save happens,
- If No, the save doesn't happen
- If a file with the same name doesn't exist...the message box should not come up and the save should happen
VBA Code:
Dim sPath As String, sName As String
sPath = ThisWorkbook.Path
sName = ThisWorkbook.Name
sName = Left(sName, InStrRev(sName, ".") - 1)
ThisWorkbook.Save
ActiveWorkbook.ExportAsFixedFormat Type:=xlTypePDF, fileName:=sPath & "\" & sName & ".pdf", _
Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=True, OpenAfterPublish:=False