Dynamic Names when using Macros to export as a PDF

carlosvz21

New Member
Joined
Jan 11, 2019
Messages
2
Hi Everyone!

I am curious to see if anyone can help me with this,

I have the following macro to export as a PDF in excel:

Sub SoA()
'
' SoA Macro
'
'
Application.ScreenUpdating = False
Sheets("Super SoA").Select
ChDir "M:\New Client\Created PDF"
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
"M:\New Client\Created PDF\Statement.pdf", Quality:= _
xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, _
OpenAfterPublish:=False
Application.ScreenUpdating = True
End Sub


We do this all the time for "n"amount of clients, after we export the Statement to pdf, we rename it to add the client's name at the begining of the file's name i.e. "John Smith - Statement.pdf"

Is there any way to code the client's name into the macro to avoid the time in renaming files? to be exported as "John Smith - Statement.pdf" instead of simply "Statement.pdf"?

it sounds silly with 1 client, but we trend to have around 2000 per day so you can imaging the impact on us.

as part of the data entry, we already have the client's name in another sheet/cell --> 'DATA'C5 (Value in this cell will be displaying "John Smith")

Thank you guys for any help you can provide with this!
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
maybe change
Code:
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
"M:\New Client\Created PDF\Statement.pdf"

to

Code:
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
"M:\New Client\Created PDF\" & Worksheets("Data").Range("C5").Value & " - Statement.pdf"
 
Upvote 0

Forum statistics

Threads
1,223,723
Messages
6,174,108
Members
452,544
Latest member
aush

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