Discussion:
PowerPoint "ExportAsFixedFormat" for saving PPT as PDF in VBS
(too old to reply)
Birke
2007-08-14 07:46:02 UTC
Permalink
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.
Steve Rindsberg
2007-08-16 03:40:11 UTC
Permalink
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?
Post by Birke
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).
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
Post by Birke
ppApplication.Quit
End Function
'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.
-----------------------------------------
Steve Rindsberg, PPT MVP
PPT FAQ: www.pptfaq.com
PPTools: www.pptools.com
================================================
Birke
2007-08-20 09:00:01 UTC
Permalink
i tried this with a clng() statement but it didn't affect ... there is still
the same problem :(
does anyone has an idea?
Post by 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?
Steve Rindsberg
2007-08-21 16:53:41 UTC
Permalink
Post by Birke
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).
Post by Birke
Post by 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?
-----------------------------------------
Steve Rindsberg, PPT MVP
PPT FAQ: www.pptfaq.com
PPTools: www.pptools.com
================================================
unknown
2007-11-15 13:59:55 UTC
Permalink
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

Loading...