[SOLVED]MS Word file - PrintOut method
-
Hello everyone, i'm back again with an new question.
I want to print a word file that i have opened in word from my code.I found out that the method i have to use is "PrintOut" but i cannot found anywhere an example on how can i use it.
All i need is a very simple example just to under--stand the way it works.
Any help is appreciated
PS: the code i use to open the file is
@
word = new QAxWidget(this);
word->setControl("Word.Application");
word->dynamicCall("Visible", true );
QAxObject* docs = word->querySubObject( "Documents" );
QVariant filename("d:/a.docx");
QVariant confirmconversions(false);
QVariant readonly(true);
QVariant addtorecentfiles(false);
QVariant passworddocument("");
QVariant passwordtemplate("");
QVariant revert(false);
QVariant background(false);
QVariant append(false);
QAxObject* doc = docs->querySubObject("Open(const QVariant&, const QVariant&, const QVariant&, const QVariant&, const QVariant&, const QVariant&,const QVariant&)", filename, confirmconversions, readonly, addtorecentfiles, passworddocument, passwordtemplate, revert);
QAxObject* print = docs->querySubObject("PrintOut(const QVariant&,const QVariant&)", background , append);
@the last line is not working :'(
Thank you
3lias -
I want the document to stay in my main window. So my code for opening the document:
@ WordDocument=new QAxWidget ("Word.Document", this-> ui-> centralWidget);
WordDocument-> setGeometry (QRect (10, 10, 621, 471)); WordDocument-> setControl ("D:/c.docx"); WordDocument-> show ();
@
And I have a PushButton for printing :
@
void MainWindow::on_printButton_clicked()
{
WordDocument->querySubObject("PrintOut()");
}
@It works perfectly unless I modify the document. If I type something to the document, and try to print it gives these errors :
QAxBase: Error calling IDispatch member PrintOut: Exception thrown by serverCode : 4605 Source : Microsoft Word Description: Bu y?ntem veya ?zellik kullan?lamaz. ??nk? bu belge, ba?ka bir uygulama program? taraf?ndan d?zenleniyor. (meaning: this method or property could not be used, other application is editing ...) Help : C:\Program Files\Microsoft Office\Office12\1055\WDMAIN11.CHM [37373] Connect to the exception(int,QString,QString,QString) signal to catch this exception