Strange issue. I want to save a sheet as PDF and put the date also in the filename. It has been working all good for this date format 01.01.2022.
But as soon as I change the date to this US format ex. 01/01/2022 , it gives me a runtime error. In the system settings, I also changed it to US region and format. So it can't be that.
Sub SavePDF()
Dim i As Integer
For i = 1 To 1
Sheets(i).ExportAsFixedFormat Type:=xlTypePDF, Filename:="C:\myfile " & Sheets(i).Range("A1") & ".pdf", _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=False
Next
End Sub
A1 is where the date is at.