This piece of code was working but all of sudden when triggered by other program (ERP software) it gives a message that a file already exists and has to be overwrited.
This file should usually have the file name and saved in the same folder where this workbook is.
Can somebody check this code if there is something wrong, or how to ignore any message (if there is duplicate for instance)?
Sub ExpPDF()
'Save PDF Document
Dim PathFile As String
Dim PathArray() As String
Dim PathPDF As String
Application.DisplayAlerts = False
'Get file path
PathFile = Application.ThisWorkbook.FullName
'Split file path in path and file ending
PathArray() = Split(PathFile, ".")
'Creat file path with ".pdf" ending
PathPDF = PathArray(0) & ".pdf"
'PDF File is saved in directory of workbook
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
PathPDF, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
:=False, OpenAfterPublish:=True
'Closes Workbook after generatin PDF
ActiveWorkbook.Saved = True
Application.Quit
Application.DisplayAlerts = True
End sub