Hi there,
I'm afraid I'm a bit of VBA newbie, so this is probably quite a straightforward thing, I hope that means someone can help me.
I've created a macro (code below) in an excel workbook that saves the workbook as a pdf file and names it according to the contencts of cell J1.
All works fine, the only problem is that if the filename already exists there is no pop up to warn the user before overwriting. The file is simply overwritten.
How do I ensure that the user is prompted before overwriting?
Here is my code:
All help will be very much appreciated.
Thanks
I'm afraid I'm a bit of VBA newbie, so this is probably quite a straightforward thing, I hope that means someone can help me.
I've created a macro (code below) in an excel workbook that saves the workbook as a pdf file and names it according to the contencts of cell J1.
All works fine, the only problem is that if the filename already exists there is no pop up to warn the user before overwriting. The file is simply overwritten.
How do I ensure that the user is prompted before overwriting?
Here is my code:
Code:
Sub SaveAsPDF()
'
' SaveAsPDF Macro
'
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
Range("J1").Value _
, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
:=False, OpenAfterPublish:=True
End Sub
All help will be very much appreciated.
Thanks