Amend VBA

Gemandshed

New Member
Joined
Apr 5, 2023
Messages
15
Office Version
  1. 2010
Hi.

I’m using the following VBA to convert all my worksheets to PDF.
However I want to change the file name to include additional text (worksheet name and “_QTR12024”
Where do I add this in the below to get this result?
Assuming it’s in the file name bit but I’ve got a hundred tabs so don’t want to get it wrong.

Thank you in advance

Sub SaveAsPDF()

Dim CurWorksheet As Worksheet

For Each CurWorksheet In ActiveWorkbook.Worksheets

CurWorksheet.ExportAsFixedFormat Type:=xlTypePDF, _

Filename:=Application.ActiveWorkbook.Path & “\” & CurWorksheet.Name, _

Quality:=xlQualityStandard, _

IncludeDocProperties:=True, _

IgnorePrintAreas:=False, _

OpenAfterPublish:=False

Next CurWorksheet

End Sub



Regards
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Hi,

How about

VBA Code:
Sub SaveAsPDF()

Dim CurWorksheet As Worksheet

For Each CurWorksheet In ActiveWorkbook.Worksheets

    CurWorksheet.ExportAsFixedFormat Type:=xlTypePDF, _
    Filename:=Application.ActiveWorkbook.Path & "\" & CurWorksheet.Name & "_QTR12024", _
    Quality:=xlQualityStandard, _
    IncludeDocProperties:=True, _
    IgnorePrintAreas:=False, _
    OpenAfterPublish:=False

Next CurWorksheet

End Sub
 
Upvote 0
thanks. What would I need to do if they want any more text? Or the text changing? What would I need to amend?
you need to change as below "YourAdditionalText"

VBA Code:
Filename:=Application.ActiveWorkbook.Path & "\" & CurWorksheet.Name & "YourAdditionalText"
 
Upvote 0
I’ve just seen it. I’m using a mobile device so it didn’t show the text to the right. sound stupid. Haha
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,182
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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