export chart to pdf

alex_peng

New Member
Joined
Jun 29, 2020
Messages
35
Office Version
  1. 2013
Hello All,

I am having issues with a really simple task. I have a chart worksheet and am trying to save it to PDF. I tried to define the chart in two ways as worksheet chart and as an chart object.



Dim chrt As Chart
Set chrt = sourcewb.Sheets("CommodityUsageChart") ' Worksheet is a chart
Set myOBJChart = Sourceworkbook.Charts(1) 'chart as an object

Here is the real issue, when I try different variations of export as fixed format I always get syntax errors. Obviously my line construct is incorrect. Any help world be greatly appreciated.

chrt.ExportAsFixedFormat(type:=xlTypePDF, Filename:=ComUsagecHARTPDFFname ,Quality:=xlQualityStandard ,OpenAfterPublish:=True
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Hi, try this:
VBA Code:
    sourcewb.Sheets("CommodityUsageChart").ExportAsFixedFormat _
        Type:=xlTypePDF, _
        Filename:=ComUsagecHARTPDFFnam, _
        Quality:=xlQualityStandard, _
        IncludeDocProperties:=True, _
        IgnorePrintAreas:=False, _
        OpenAfterPublish:=False  ' or may be True
 
Upvote 0
Thanks for the response ZVI.

It gave me an error saying no object, so I used the one defined as a chart object and it worked like a charm. Thanks so much for your help.
 
Upvote 0
Glad you found the solution!
 
Upvote 0

Forum statistics

Threads
1,214,375
Messages
6,119,166
Members
448,870
Latest member
max_pedreira

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