Print to pdf not working correctly

PamL

New Member
Joined
Nov 22, 2021
Messages
2
Office Version
  1. 365
Platform
  1. Windows
Hi,

I'm trying to save every sheet as a separate pdf using the code shown below. I can't get it to work. If I change the highlighted line to ActiveSheet.ExportAsFixedFormat I get the correct file names but all the files are the same when you open them so I feel like it's an issue with this line. I'm new to vba so I'm sure it's something obvious that I'm missing. Any help your be greatly appreciated.

Thanks!

Sub PrintToPDF()

Dim ws As Worksheet

For Each ws In Worksheets

ws.ExportAsFixedFormat _
Type:=xlTypePDF, _
fileName:=ws.Name, _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=False

Application.CutCopyMode = False

Next ws

End Sub
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college

Forum statistics

Threads
1,214,833
Messages
6,121,868
Members
449,053
Latest member
Mesh

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