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!
 

Some videos you may like

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.

fhqwgads

Board Regular
Joined
Jul 17, 2018
Messages
173
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"
 

Watch MrExcel Video

Forum statistics

Threads
1,090,459
Messages
5,414,643
Members
403,540
Latest member
mmorejon1215

This Week's Hot Topics

Top