Saving Pivot table to PDF

saloelrn1988

New Member
Joined
Apr 14, 2020
Messages
32
Office Version
  1. 365
Platform
  1. Windows
Hi I need Help!

i am able to save my Pivot table in PDF however upon saving it saves other pages with blanks. i wanted to save it up until the cell containing data(my last cell may vary because I'm using different data per week).

See below coding that i used:

Sub Save_PDF()
'
' Save_PDF Macro
' Save pivot table as PDF
Dim saveLocation As String
saveLocation = "C:\Users\elon\Desktop\" & Sheets("email data").Range("B3")

Sheets("pivot table").Select
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=saveLocation _
, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
:=False, OpenAfterPublish:=True
Worksheets("raw data").Select
End Sub
 
Actually, I see that your path was initially "c:\users\elon\desktop...", which presumable worked. However, in your latest code that you posted, you have "c:\users\elXXXXXXXXon\Desktop...".?????
 
Upvote 0

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Still a runtime error:

1588966586289.png
 
Upvote 0
Actually, I see that your path was initially "c:\users\elon\desktop...", which presumable worked. However, in your latest code that you posted, you have "c:\users\elXXXXXXXXon\Desktop...".?????
Actually i just deleted my name in the initial coding, then i typed it back again base on the coding that you have given
 
Upvote 0
y
You're still getting an error with our little test? That's surprising.

Did your original code work?
Yes, however it also save like 6 to 7 blank pages, i wanted to get rid of those unnecessary blank pages
 
Upvote 0
Try checking whether the file already exists, and delete it if so prior to exporting to PDF.
 
Upvote 0
Another possibility is that the file may already be opened by another program, and so you won't be able to overwrite and save it.
 
Upvote 0
:):):):)
Try checking whether the file already exists, and delete it if so prior to exporting to PDF.
i tried deleting the original file created then it works perfectly. Thanks for the patience.

Have a lovely weekend:):)
 
Upvote 0
That's great, I'm glad I could help. You too have yourself a great weekend. Cheers!
 
Upvote 0

Forum statistics

Threads
1,214,414
Messages
6,119,373
Members
448,888
Latest member
Arle8907

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