ipbr21054
Well-known Member
- Joined
- Nov 16, 2010
- Messages
- 5,699
- Office Version
- 2007
- Platform
- Windows
Hi,
I have the working code in use shown below.
When i receive the message "File Already Exists On The Desktop" i click on OK then i need to go to the desktop to delete the file then go back and start again.
Can we add a line of code so when i see this message then clicking on OK deletes the file for me.
The path & file name will always be the same & supplied below for you.
C:\Users\Ian\Desktop\DISCOVERY II CODES.pdf
I have the working code in use shown below.
When i receive the message "File Already Exists On The Desktop" i click on OK then i need to go to the desktop to delete the file then go back and start again.
Can we add a line of code so when i see this message then clicking on OK deletes the file for me.
The path & file name will always be the same & supplied below for you.
C:\Users\Ian\Desktop\DISCOVERY II CODES.pdf
Code:
Private Sub CommandButton1_Click()Dim Filename As String
Filename = "C:\Users\Ian\Desktop\DISCOVERY II CODES.pdf"
If FileExists(Filename) Then
MsgBox "File Already Exists On The Desktop", vbCritical, "Land Rovery Discovery II Codes"
Exit Sub
Else
MsgBox "File Saved Sucessfully On The Desktop", vbInformation, "Land Rovery Discovery II Codes"
End If
Sheets("DR SITE").Range("A1:K16").ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
"C:\Users\Ian\Desktop\DISCOVERY II CODES.pdf", Quality:= _
xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False
End Sub