1

After searching a bit I still haven't got what I need. I'm trying to convert various files to PDF using VB.Net and referencing various MS Office components like Word/Excel/PowerPoint as either COM objects or by using the PIA (Office Interop Assemblies). In the end I want to use the COM method because it is version independent and that's important.

For Word and Excel I can make it work both ways. But for PowerPoint I'm running into problems and would appreciate some suggestions.

Here's the 2 methods

COM

Dim appPP As Object = CreateObject("PowerPoint.Application") Dim docPP As Object = appPP.Presentations.Open(strAttachmentFileName) '2 is Microsoft.Office.Interop.PowerPoint.PpFixedFormatType.ppFixedFormatTypePDF docPP.ExportAsFixedFormat(strNewFileName, 2) docPP.Close() appPP.Quit() 

This method gets an error at the Export line - Type mismatch. (Exception from HRESULT: 0x80020005 (DISP_E_TYPEMISMATCH))

PIA - this works ok

Imports Microsoft.Office.Interop ' PowerPoint requires this, to add a reference use COM - MS Office Type Library of same version as interop Imports Microsoft.Office.Core Dim appPP As New PowerPoint.Application Dim docPP As PowerPoint.Presentation = appPP.Presentations.Open(strAttachmentFileName) docPP.ExportAsFixedFormat(strNewFileName, PowerPoint.PpFixedFormatType.ppFixedFormatTypePDF) docPP.Close() appPP.Quit() 

EDIT

Also in the COM version I tried the fully qualified version including references to the PIA and Office Core like this

docPP.ExportAsFixedFormat(strNewFileName, PowerPoint.PpFixedFormatType.ppFixedFormatTypePDF, PowerPoint.PpFixedFormatIntent.ppFixedFormatIntentScreen, MsoTriState.msoFalse, PowerPoint.PpPrintHandoutOrder.ppPrintHandoutVerticalFirst, PowerPoint.PpPrintOutputType.ppPrintOutputSlides, MsoTriState.msoFalse, Nothing, PowerPoint.PpPrintRangeType.ppPrintAll, "", False, False, False, False, False)

And it still gets the error

1 Answer 1

1

After experimenting with the COM version of the ExportAsFixedFormat I think there is a bug in the COM object. I did find a workable solution tho

docPP.SaveAs(strNewFileName, 32) 

I'm not sure what the version compatibility is on that. I have Office 2010.

Sign up to request clarification or add additional context in comments.

1 Comment

For reference, there is another semi-related question here on SO that came to the same conclusion.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.