Save single chart to PDF

W

Wi11y13

From within Powerpoint and using a macro with VBA, how can I save the current
chart to a PDF file. I want to give the user an option to either print out
the chart immediatley or save it as a PDF to print out later (with no ability
to change it).

Thanks
 
C

Chirag

PowerPoint 2007 supports saving as PDF format through the SaveAs() method of
the presentation object. If you want to save only a single slide as PDF,
make a copy of the presentation and remove all slides except your slide with
chart and then save the new single slide presentation as PDF.

- Chirag

PowerShow - View multiple PowerPoint slide shows simultaneously
http://officeone.mvps.org/powershow/powershow.html
 
W

Wi11y13

Sorry, I gues I need to be more specific about what I am trying to do. This
last chart has variable information on it from the user. During a slide show
the user is asked to input (through VBA Macro) certain information that will
appear on the chart. Then when they click a "print" button that I have
created this last chart will print to their default printer (also using a VBA
macro). What I want to do is within that macro I want to give them an
opportunity to save this chart (with the variable information inserted on it)
in a PDF format rather than printing the chart out immediately.

Does that help?
 
W

Wi11y13

Sorry, I gues I need to be more specific about what I am trying to do. This
last chart has variable information on it from the user. During a slide show
the user is asked to input (through VBA Macro) certain information that will
appear on the chart. Then when they click a "print" button that I have
created this last chart will print to their default printer (also using a VBA
macro). What I want to do is within that macro I want to give them an
opportunity to save this chart (with the variable information inserted on it)
in a PDF format rather than printing the chart out immediately.

ActivePresentation.Slides("CertificateSlide").SlideIndex FileName:=strPath &
"\" & "Certificate.PDF" = ppSaveAsPDF

Does that help?
 
W

Wi11y13

ok - thanks
--
Wi11y13


Steve Rindsberg said:
That snippet makes no sense to me.

This:
ActivePresentation.Slides("CertificateSlide").SlideIndex

returns the slide index of the slide named "CertificatSlide"

So that reduces to:

42 FileName:=strPath & "\" & "Certificate.PDF" = ppSaveAsPDF

which reduces to:

42 "C:\SomePath\Certificate.PDF" = ppSaveAsPDF

which, from VBA's point of view, is not workable code.

If there were a SaveAs method for individual slides, we might be able to make
something similar work. But there isn't. So my suggestion still stands: save a
copy of the presentation, delete everything but the slide you want, then save
the PRESENTATION as PDF.



==============================
PPT Frequently Asked Questions
http://www.pptfaq.com/

PPTools add-ins for PowerPoint
http://www.pptools.com/

Don't Miss the PPTLive User Conference! Atlanta | Oct 11-14
 
W

Wi11y13

Thanks Steve. I have now been able to delete all of the slides but the one I
want to save as a PDF file. But after I saved it Adobe state that it ican not
open it because it is either not a supported file type or because it was
damaged. Here is the code that I am using to delete the slides and save the
file....

Sub SaveMe()

Dim x As Integer
Dim pathName As String
Dim currentSlide As Long

x = 0
pathName = ActivePresentation.Path
currentSlide = ActivePresentation.Slides("CertificateSlide").SlideIndex

Do While x = 0
currentSlide = currentSlide - 1

If currentSlide = 0 Then
x = 1

Else
ActivePresentation.Slides(currentSlide).Delete
End If
Loop

ActivePresentation.SaveAs FileName:=pathName & "\" & "Certificate.PDF" =
ppSaveAsPDF
MsgBox ("Saved Certificate")
End Sub


Also after I exit this all of my slides have been deleted (except for the
last one) which makes sense. So I need a way to exit gracefully without
actually deleting all of the slides in the original slide show. Any help here
would also be greatly appreciated.

As you can tell I am very new at this but I am learning alot thanks to this
site and your help.
 
W

Wi11y13

I have now been able to delete all of the slides but the one I
want to save as a PDF file. But after I saved it Adobe state that it ican not
open it because it is either not a supported file type or because it was
damaged. Here is the code that I am using to delete the slides and save the
file. Is there something wrong with my SaveAs statement?

Sub SaveMe()

Dim x As Integer
Dim pathName As String
Dim currentSlide As Long

x = 0
pathName = ActivePresentation.Path
currentSlide = ActivePresentation.Slides("CertificateSlide").SlideIndex

Do While x = 0
currentSlide = currentSlide - 1

If currentSlide = 0 Then
x = 1

Else
ActivePresentation.Slides(currentSlide).Delete
End If
Loop

ActivePresentation.SaveAs pathName & "\" & (userName) & " Certificate.PDF"
MsgBox ("Saved Certificate")
End Sub
 
W

Wi11y13

Never Mind - I got it to work...

ActivePresentation.SaveAs pathName & "\" & (userName) & " Certificate.PDF",
ppSaveAsPDF
 
W

Wi11y13

Steve. The code now works. I am posting it for completeness to this site for
others to see... Please note the userName is predefined as Public...The code
deletes all slides except for the last slide and then saves the last slide as
a PDF file.

Sub SaveMe()

Dim x As Integer
Dim pathName As String
Dim currentSlide As Long

x = 0
pathName = ActivePresentation.Path
currentSlide = ActivePresentation.Slides("CertificateSlide").SlideIndex



Do While x = 0
currentSlide = currentSlide - 1

If currentSlide = 0 Then
x = 1

Else
ActivePresentation.Slides(currentSlide).Delete
End If
Loop

ActivePresentation.SaveAs pathName & "\" & (userName) & "
Certificate.PDF", ppSaveAsPDF
MsgBox ("Saved Certificate as " & (userName) & " Certificate.PDF")



End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top