P
Paul
Hi,
I am developing an application which uses office automation with Office
2007, which converts doc, xls and ppt files into pdf format. The application
is in C (long story), and uses the ExportAsFixedFormat method. This works
fine for Word and Excel, however I have a problem with Powerpoint which I
can't understand.
I have working code which uses the "SaveAs" method into HTML for all three
applications without issue, so I know the underlying dispatch/parameter
handling code is fine.
With PowerPoint, I keep getting 0x80020005 (type mismatch) as a result of
the ExportAsFixedFormat call. According to the object browser in PowerPoint,
and information from Microsoft, the ExportAsFixedFormat function requires two
arguments, the output filename and the FixedFormatType.
I can execute the following fine, from Visual Basic within a loaded
PowerPoint document:
Application.ActivePresentation.ExportAsFixedFormat "c:\work\zot.pdf",
ppFixedFormatTypePDF
Note, the constant is value 2, so the following also works:
Application.ActivePresentation.ExportAsFixedFormat "c:\work\zot.pdf", 2
In C, before calling the method, I prepare the arguments as follows:
VARIANTARG params[2];
VariantInit(¶ms[0]);
VariantInit(¶ms[1]);
params[0].vt = VT_I4;
params[0].lVal = 2;
params[1].vt = VT_BSTR;
params[1].bstrVal = targetFileBstr;
Note in C - the argument order has to be reversed (I've tried the other way
around and it makes no difference - same error).
My initial suspicion was the constant value "2" should be another type
instead of VT_I4, but after trying all other integer types, same result.
Does anyone have any ideas what might be wrong? Its frustrating to see that
this works in Word and Excel, and not PowerPoint.
Cheers.
I am developing an application which uses office automation with Office
2007, which converts doc, xls and ppt files into pdf format. The application
is in C (long story), and uses the ExportAsFixedFormat method. This works
fine for Word and Excel, however I have a problem with Powerpoint which I
can't understand.
I have working code which uses the "SaveAs" method into HTML for all three
applications without issue, so I know the underlying dispatch/parameter
handling code is fine.
With PowerPoint, I keep getting 0x80020005 (type mismatch) as a result of
the ExportAsFixedFormat call. According to the object browser in PowerPoint,
and information from Microsoft, the ExportAsFixedFormat function requires two
arguments, the output filename and the FixedFormatType.
I can execute the following fine, from Visual Basic within a loaded
PowerPoint document:
Application.ActivePresentation.ExportAsFixedFormat "c:\work\zot.pdf",
ppFixedFormatTypePDF
Note, the constant is value 2, so the following also works:
Application.ActivePresentation.ExportAsFixedFormat "c:\work\zot.pdf", 2
In C, before calling the method, I prepare the arguments as follows:
VARIANTARG params[2];
VariantInit(¶ms[0]);
VariantInit(¶ms[1]);
params[0].vt = VT_I4;
params[0].lVal = 2;
params[1].vt = VT_BSTR;
params[1].bstrVal = targetFileBstr;
Note in C - the argument order has to be reversed (I've tried the other way
around and it makes no difference - same error).
My initial suspicion was the constant value "2" should be another type
instead of VT_I4, but after trying all other integer types, same result.
Does anyone have any ideas what might be wrong? Its frustrating to see that
this works in Word and Excel, and not PowerPoint.
Cheers.