Aussie5380
New Member
- Joined
- Sep 30, 2022
- Messages
- 32
- Office Version
- 2019
- Platform
- Windows
Hi there,
I have a macro already that prints to PDF and asks for a save location, however i wanted to add another macro ii made into it so it names the files of cells in the sheet. The codes i have so far are:
Macro to print and ask for save location:
Macro to print to PDF with cell names:
Is there a way i can combine these together?
Thank you in advance
I have a macro already that prints to PDF and asks for a save location, however i wanted to add another macro ii made into it so it names the files of cells in the sheet. The codes i have so far are:
Macro to print and ask for save location:
VBA Code:
Sub allow_user_to_select_save_location()
Dim FileSaveName As String
Dim fName As String
ActiveWorkbook.Save
fName = "Name Here"
FileSaveName = Application.GetSaveAsFilename(InitialFileName:=fName, filefilter:="Excel Files(*.xlsm),*.xlsm", _
Title:="Please Select Location To Save File")
ActiveWorkbook.SaveAs FileName:=FileSaveName, FileFormat:=52
End Sub
Macro to print to PDF with cell names:
VBA Code:
Sub PTPDF2()
Dim pdfName As String
pdfName = Sheets("Leave Loading").Range("F13") & ", " & Sheets("Leave Loading").Range("F12") & "- " & Sheets("Leave Loading").Range("F14") & "- " & "Leave Loading" & ".pdf"
Application.ScreenUpdating = False
ActiveWorkbook.ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, FileName:=pdfName, OpenAfterPublish:=True
Application.ScreenUpdating = True
End SuB
Is there a way i can combine these together?
Thank you in advance