I'm using excel 2003 and I've got Acrobat Distiller/Professional Version 8.
Currently, I've got some vba code that creates a ppt presentation and then
saves it as a ppt file based on the name of the excel file from which a
series of charts and text are imported. The code I'm using to save the ppt
works great (see below). Now, I would like to print the ppt file into a pdf
file. I found some vba code on the net that appears relevant to my problem,
but I can't figure out how to modify it for my purposes.
Thanks for any advice.
***code I'm using to save ppt file
Dim sName As String
sName = ActiveWorkbook.Name
sName = Mid$(sName, 1, InStr(sName, ".") - 1)
sName = ActiveWorkbook.Path & "\" & sName & ".ppt"
PP.ActivePresentation.SaveAs Filename:=sName
Application.DisplayAlerts = True
***Code I found on the net to print an excel range to pdf file
Private Sub CommandButton1_Click()
' Define the postscript and .pdf file names.
Dim PSFileName as String
Dim PDFFileName as String
PSFileName = "c:\myPostScript.ps"
PDFFileName = "c:\myPDF.pdf"
' Print the Excel range to the postscript file
Dim MySheet As WorkSheet
Set MySheet = ActiveSheet
MySheet.Range("myRange").PrintOut copies:=1, preview:=False,
ActivePrinter:="Acrobat Distiller", printtofile:=True, collate:=True,
prtofilename:=PSFileName
' Convert the postscript file to .pdf
Dim myPDF As PdfDistiller
Set myPDF = New PdfDistiller
myPDF.FileToPDF PSFileName, PDFFileName, ""
End Sub
'Save ppt. presentation as ppt.
Dim sName As String
sName = ActiveWorkbook.Name
sName = Mid$(sName, 1, InStr(sName, ".") - 1)
sName = ActiveWorkbook.Path & "\" & sName & ".ppt"
PP.ActivePresentation.SaveAs Filename:=sName
Application.DisplayAlerts = True
'Print ppt. presentation as pdf and save pdf
With PP.ActivePresentation.PrintOptions
.PrintInBackground = msoFalse
.RangeType = ppPrintAll
.Collate = msoTrue
.PrintColorType = ppPrintColor
.FitToPage = msoFalse
.FrameSlides = msoFalse
.ActivePrinter = "Adobe PDF"
End With
PP.ActivePresentation.SaveAs Filename:=sName
Any ideas how to do that? Thanks.
That would be an AdobePDF driver setting, I'm pretty sure.
There's an option to have it prompt for a file name or just create a file
automatically. Check for that; I'm not certain you can control *where* the file's
produced in auto-mode, but it may automatically do what you want.
==============================
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
Sub ppt_to_pdf ()
Dim psName As String
Dim pdfName As String
psName = ActiveWorkbook.Name
psName = Mid$(psName, 1, InStr(psName, ".") - 1)
psName = ActiveWorkbook.Path & "\" & psName & ".ps"
pdfName = ActiveWorkbook.Name
pdfName = Mid$(pdfName, 1, InStr(pdfName, ".") - 1)
pdfName = ActiveWorkbook.Path & "\" & pdfName & ".pdf"
PP.ActivePresentation.PrintOut PrintToFile:=psName
Dim myPDF As PdfDistiller
Set myPDF = New PdfDistiller
myPDF.FileToPDF psName, pdfName, ""
Kill psName
PP.Quit
End sub
On 9/10/09 1:55 AM, in article
D215FA74-E839-417D...@microsoft.com, "intoit"
<int...@discussions.microsoft.com> wrote:
--
David M. Marcovitz
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/
Microsoft PowerPoint MVP
Associate Professor, Loyola University Maryland
Nope. You can dim variables pretty much anywhere you like.
It's generally considered "good form" to put the statements at the top of the
Sub/Function, but sometimes it makes more sense (ie, for code you're going to
copy/paste into a routine) to Dim the variables before you're going to use 'em.
Thanks for posting the results!