I am using the below code in a button to Open and Auto save a copy of excel file to PDF. All works fine EXCEPT; the file name the PDF file is saving as adds the name of the Folder it saves in to the beginning of it
I want the file name to be Fee Calculation - (C1) but it is coming through as Folder Name - Fee Calculation - (C1)
I know it's to do with the line of code in bold and I've tried heaps of suggestions from forums but can't get anything to work. .. any ideas?
Sub PrintSelectionToPDF()
Dim invoiceRng As Range
Dim strfile As String
'Setting range to be printed
Set invoiceRng = Range("A1:D40")
'setting file name with a time stamp.
strfile = Range("C1") & " - " & Format(Now(), "ddmmyy") & ".pdf"
'setting the fulli qualified name. The resultent pdf will be saved where the main file exists.
strfile = ThisWorkbook.Path & "Fee Calculation - " & strfile
invoiceRng.ExportAsFixedFormat _
Type:=xlTypePDF, _
Filename:=strfile, _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=True
End Sub
I want the file name to be Fee Calculation - (C1) but it is coming through as Folder Name - Fee Calculation - (C1)
I know it's to do with the line of code in bold and I've tried heaps of suggestions from forums but can't get anything to work. .. any ideas?
Sub PrintSelectionToPDF()
Dim invoiceRng As Range
Dim strfile As String
'Setting range to be printed
Set invoiceRng = Range("A1:D40")
'setting file name with a time stamp.
strfile = Range("C1") & " - " & Format(Now(), "ddmmyy") & ".pdf"
'setting the fulli qualified name. The resultent pdf will be saved where the main file exists.
strfile = ThisWorkbook.Path & "Fee Calculation - " & strfile
invoiceRng.ExportAsFixedFormat _
Type:=xlTypePDF, _
Filename:=strfile, _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=True
End Sub