Macro to print to PDF with cell values as name (Completed) but need a save as option added

Aussie5380

New Member
Joined
Sep 30, 2022
Messages
32
Office Version
  1. 2019
Platform
  1. 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:

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 :)
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
sorry let me clarify, the top macro lets me save the workbook to a location, but i would like to print to PDF and have it named from the range of cells in the second VBA code, but also ask me where to save.... if that makes sense
 
Upvote 0

Forum statistics

Threads
1,223,239
Messages
6,170,947
Members
452,368
Latest member
jayp2104

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top