Good afternoon,
Apologies for this being excel and not access, I was hoping someone could point me in the right direction.
I'm trying to break up a save and create pdf module to check for the existence of the file it's about to create. I've managed to get a cell to display TRUE or FALSE if the file exists or not.
Now i'm trying to add in an If statement in the VBA to display a msg box saying the file exists. I'm not very confident with VBA, but I've fumbled around a little:
Apologies for this being excel and not access, I was hoping someone could point me in the right direction.
I'm trying to break up a save and create pdf module to check for the existence of the file it's about to create. I've managed to get a cell to display TRUE or FALSE if the file exists or not.
Now i'm trying to add in an If statement in the VBA to display a msg box saying the file exists. I'm not very confident with VBA, but I've fumbled around a little:
Code:
Sub SAVEREPORTANDPDF()
Dim FileName As String
Dim Path As String
Dim filecheckl As String
filecheck1 = Range("AU11").Value 'Sets the value of FileCheck1
'Checks the value of File exists in the form
If filecheck1 = "true" Then MsgBox "File Already Exists"
Else
'save the excel file
Path = "R:\" '
FileName = Range("AU10").Value & ".xlsm"
ActiveWorkbook.SaveAs Path & FileName, xlOpenXMLWorkbookMacroEnabled
'now create the pdf
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, FileName:=Range("AU15").Value _
, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
:=False, OpenAfterPublish:=True
End If
End Sub