Aussie5380
New Member
- Joined
- Sep 30, 2022
- Messages
- 32
- Office Version
- 2019
- Platform
- Windows
I'm trying to make a print button Macro that prints to pdf, but also names the file based on vales in several cells.
I would like the naming convention to look like this:
Cells on Sheet:
F12 - First Name
F13 - Surname
F14 - Staff Number
What i want the save name to look like is this:
SURNAME, First name - Staff number - Leave Loading.PDF
SMITH, John - 89569812 - Leave Loading.PDF
Is this achievable? Im still quite new to macro writing, and any help would be greatly appreciated.
My print code so far looks like this, just not sure how to add the naming convention?
Sub print_sheets_by_name()
Worksheets("Leave Loadiing").PrintOut
End Sub
I have also tried to add these lines but im getting errors back and im not sure what im missing:
Dim FileName As String
FileName = Worksheets("Leave Loading").Range("F13") & (",") & ("F12") & "-" & ("F14") & "Leave Loading" & ".pdf"
Worksheets(PrintSheets).ExportAsFixedFormat _
Type:=xlTypePDF, _
FileName:=FileName, _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=True
Thanks in advance!
I would like the naming convention to look like this:
Cells on Sheet:
F12 - First Name
F13 - Surname
F14 - Staff Number
What i want the save name to look like is this:
SURNAME, First name - Staff number - Leave Loading.PDF
SMITH, John - 89569812 - Leave Loading.PDF
Is this achievable? Im still quite new to macro writing, and any help would be greatly appreciated.
My print code so far looks like this, just not sure how to add the naming convention?
Sub print_sheets_by_name()
Worksheets("Leave Loadiing").PrintOut
End Sub
I have also tried to add these lines but im getting errors back and im not sure what im missing:
Dim FileName As String
FileName = Worksheets("Leave Loading").Range("F13") & (",") & ("F12") & "-" & ("F14") & "Leave Loading" & ".pdf"
Worksheets(PrintSheets).ExportAsFixedFormat _
Type:=xlTypePDF, _
FileName:=FileName, _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=True
Thanks in advance!