Hello all,
I have the code below to convert and save the active worksheet as a PDF in a specific file location. Works great for what I am doing. How can this be amended to prompt if the file name being saved already exists in the folder to overwrite the existing folder or cancel the operation?
Sub SaveAsPDF()
'Saves active worksheet as pdf using Range
'of AX2,AX4'
Dim fName As String
With ActiveSheet
fName = .Range("AX2").Value & "." & .Range("B14").Value & " " & .Range("AX4").Value
.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
"C:\Users\Tim M\Dropbox\PCL\PCL Work Orders\Tractor Internal Work Orders\" & fName, Quality:=xlQualityStandard, _
IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=True
End With
End Sub
I have the code below to convert and save the active worksheet as a PDF in a specific file location. Works great for what I am doing. How can this be amended to prompt if the file name being saved already exists in the folder to overwrite the existing folder or cancel the operation?
Sub SaveAsPDF()
'Saves active worksheet as pdf using Range
'of AX2,AX4'
Dim fName As String
With ActiveSheet
fName = .Range("AX2").Value & "." & .Range("B14").Value & " " & .Range("AX4").Value
.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
"C:\Users\Tim M\Dropbox\PCL\PCL Work Orders\Tractor Internal Work Orders\" & fName, Quality:=xlQualityStandard, _
IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=True
End With
End Sub
Last edited: