I would like to do the following:
I want to create a COM object for an excel file, and print this file to PdfCreator, using the AutoSave options to prevent the gui to pop up. (I'm using Qt and C++, but that should not be a constraint)
I use a COM object for PdfCreator to change the autosave options, then use a COM object for Excel to change the data inside the file, and finally use the Excel COM object to print to PdfCreator. Is this supposed to work, or are the options in the PdfCreator COM object not shared with the printer used from inside the Excel COM object?
QAxObject* pdf = new QAxObject("PDFCreator.clsPDFCreator");
QAxObject* oldOptions = pdf->querySubObject("cOptions");
QAxObject* options = pdf->querySubObject("cOptions");
options->setProperty("UseAutosave", 1);
options->setProperty("UseAutosaveDirectory", 1);
options->setProperty("AutosaveFormat", 0);
options->setProperty("AutosaveDirectory", "C:\\\\temp");
options->setProperty("AutosaveFilename", "report.pdf");
pdf->setProperty("cOptions", options->asVariant());
pdf->dynamicCall("cSaveOptions(PDFCreator.clsPDFCreatorOptions)", options->asVariant());
QAxObject* excel = new QAxObject("Excel.Application");
QAxObject* workbooks = excel->querySubObject( "Workbooks" );
QAxObject* workbook = workbooks->querySubObject( "Open(const QString&)", "report.xls");
QAxObject* worksheets = workbook->querySubObject( "Worksheets" );
QAxObject* worksheet = worksheets->querySubObject( "Item( int )", 1 );
// manipulate the data in the excel file...
workbook->dynamicCall("Save()");
worksheet->dynamicCall( "PrintOut(int,int,int,bool,String)",
1, 100, 1, QVariant(false), "PDFCreator");
workbook->dynamicCall("Close()");
excel->dynamicCall("Quit()");
pdf->dynamicCall("cSaveOptions(PDFCreator.clsPDFCreatorOptions)", oldOptions->asVariant());
pdf->dynamicCall("cClose()");