PowerPoint "ExportAsFixedFormat" for saving PPT as PDF in VBS

G

Guest

hi @ all,

i downloaded the plugin for office 2007 for pdf saving. now i have to frite
an vbs script that take 2 parameters. a source file and a destination file.
the task is that the source ppt is transfered in an pdf (pdfa with iso
standard is the final task).

therefore i use the following vbs procedure:

Function Ppt2PDFA(pptFilePath, pdfFilePath)
'definitions for powerpoint export as pdf/a
Const ppWindowMinimized = 2
Const ppFixedFormatTypePDF = 2
Const ppFixedFormatIntentPrint = 2 '(1 for screen; 2 for print)

Dim ppApplication
Set ppApplication = CreateObject("PowerPoint.Application")
ppApplication.Activate
ppApplication.Presentations.Open (pptFilePath)

'Sub ExportAsFixedFormat(
' Path As String,
' FixedFormatType As PpFixedFormatType,
' [Intent As PpFixedFormatIntent = ppFixedFormatIntentScreen],
' [FrameSlides As MsoTriState],
' [HandoutOrder As PpPrintHandoutOrder = ppPrintHandoutVerticalFirst],
' [OutputType As PpPrintOutputType = ppPrintOutputSlides],
' [PrintHiddenSlides As MsoTriState],
' [PrintRange As PrintRange],
' [RangeType As PpPrintRangeType = ppPrintAll],
' [SlideShowName As String],
' [IncludeDocProperties As Boolean = Falsch],
' [KeepIRMSettings As Boolean = Wahr],
' [DocStructureTags As Boolean = Wahr],
' [BitmapMissingFonts As Boolean = Wahr],
' [UseISO19005_1 As Boolean = Falsch],
' [ExternalExporter])

'=== CRITICAL LINE ===>>
ppApplication.Presentations.Application.ActivePresentation.ExportAsFixedFormat pdfFilePath, ppFixedFormatTypePDF

ppApplication.Quit
End Function

the marked line is the critical line because here o get the following message:


"Laufzeitfehler in Microsoft VBScript: Typen unverträglich:
'ExportAsFixedFormat' "

this means type missmatch for 'ExportAsFixedFormat'. i can make sure that
the first parameter IS a string.

when i try this in VB then i will get a correct result. not this error.

what is the fault ???

thx for any helpfull hint or solution.
 
S

Steve Rindsberg

I'm not a VBS user but I think perhaps it doesn't allow strongly typed variables and constants?

PowerPoint is expecting a Long for ppFixedFormatTypePDF
I'm guessing that it's getting a variant instead.
Is there any way of forcing VBS to pass a long?


hi @ all,

i downloaded the plugin for office 2007 for pdf saving. now i have to frite
an vbs script that take 2 parameters. a source file and a destination file.
the task is that the source ppt is transfered in an pdf (pdfa with iso
standard is the final task).

therefore i use the following vbs procedure:

Function Ppt2PDFA(pptFilePath, pdfFilePath)
'definitions for powerpoint export as pdf/a
Const ppWindowMinimized = 2
Const ppFixedFormatTypePDF = 2
Const ppFixedFormatIntentPrint = 2 '(1 for screen; 2 for print)

Dim ppApplication
Set ppApplication = CreateObject("PowerPoint.Application")
ppApplication.Activate
ppApplication.Presentations.Open (pptFilePath)

'Sub ExportAsFixedFormat(
' Path As String,
' FixedFormatType As PpFixedFormatType,
' [Intent As PpFixedFormatIntent = ppFixedFormatIntentScreen],
' [FrameSlides As MsoTriState],
' [HandoutOrder As PpPrintHandoutOrder = ppPrintHandoutVerticalFirst],
' [OutputType As PpPrintOutputType = ppPrintOutputSlides],
' [PrintHiddenSlides As MsoTriState],
' [PrintRange As PrintRange],
' [RangeType As PpPrintRangeType = ppPrintAll],
' [SlideShowName As String],
' [IncludeDocProperties As Boolean = Falsch],
' [KeepIRMSettings As Boolean = Wahr],
' [DocStructureTags As Boolean = Wahr],
' [BitmapMissingFonts As Boolean = Wahr],
' [UseISO19005_1 As Boolean = Falsch],
' [ExternalExporter])

'=== CRITICAL LINE ===>>>
ppApplication.Presentations.Application.ActivePresentation.ExportAsFixedFormat pdfFilePath, ppFixedFormatTypePDF

ppApplication.Quit
End Function

the marked line is the critical line because here o get the following message:


"Laufzeitfehler in Microsoft VBScript: Typen unverträglich:
'ExportAsFixedFormat' "

this means type missmatch for 'ExportAsFixedFormat'. i can make sure that
the first parameter IS a string.

when i try this in VB then i will get a correct result. not this error.

what is the fault ???

thx for any helpfull hint or solution.
 
G

Guest

i tried this with a clng() statement but it didn't affect ... there is still
the same problem :(
does anyone has an idea?
 
S

Steve Rindsberg

i tried this with a clng() statement but it didn't affect ... there is still
the same problem :(
does anyone has an idea?

I don't, but I'm betting if you post the question to a VBS newsgroup, someone will have run across
the same problem and solved it (maybe with a different app than PPT but the same solution should
apply here as well).
 
C

Chris Priest

I spent ages trying to get this to work.

In the end I looked in the Powerpoint PIA using .Net Reflector and noticed that there is now a ppSaveAsPDF entry in the PpSaveAsFileType enumeration.

I tried this with the Presentation.SaveAs method and it worked! (even though the documentation says to use ExportAsFixedFormat)

EggHeadCafe - .NET Developer Portal of Choice
http://www.eggheadcafe.com
 
Joined
Jul 30, 2008
Messages
1
Reaction score
0
Thanks for this

I just spent hours pulling my hair out with the same issue you experienced. I was about to give up and look for a third-party component to do the job for me. Thanks for suggesting the SaveAs method. I should have thought of that.
 
Top