Results 1 to 4 of 4

Thread: Getting Microsoft Word Object to SaveAs

  1. #1
    Join Date
    May 2008
    Posts
    2
    Thanks
    1
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Getting Microsoft Word Object to SaveAs

    I am working with QAxObjects to access Microsoft Word and can open and manipulate files but am struggling to get the SaveAs method to work. Does anyone out there have a working example they would be prepared to share?

    Thank you

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Getting Microsoft Word Object to SaveAs

    I suppose not that many people on this forum are using ActiveQt since it's only part of commercial Qt/Win. But perhaps we can help if you attach the generated C++ header (dumpcpp) and paste some code what you've tried so far.
    J-P Nurmi

  3. #3
    Join Date
    Apr 2007
    Location
    Ilsfeld, Germany
    Posts
    16
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Getting Microsoft Word Object to SaveAs

    Hi,

    this seems to work here.

    HTH, Bernd
    --
    Qt Code:
    1. #include <QtGui>
    2. #include <QAxObject>
    3. #include <QAxWidget>
    4.  
    5. int main(int argc, char **argv)
    6. {
    7. QApplication a(argc, argv);
    8.  
    9. QAxWidget word("Word.Application");
    10. word.setProperty("Visible", true);
    11. QAxObject * documents = word.querySubObject("Documents");
    12. documents->dynamicCall("Add (void)");
    13. QAxObject * document = word.querySubObject("ActiveDocument");
    14.  
    15. document->dynamicCall("SaveAs (const QString&)", QString("e:/test/docbyqt.doc"));
    16. document->dynamicCall("Close (boolean)", false);
    17. word.dynamicCall("Quit (void)");
    18. return 0;
    19. }
    To copy to clipboard, switch view to plain text mode 

  4. The following user says thank you to bst for this useful post:

    jvwebb (1st September 2008)

  5. #4
    Join Date
    May 2008
    Posts
    2
    Thanks
    1
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: Getting Microsoft Word Object to SaveAs

    Thanks for the help. As a further complication I needed to save in Word's filtered html format. The following code seems to work.

    Qt Code:
    1. //Start Word
    2. my_app = new QAxObject("Word.Application", this);
    3. QAxObject* my_docs = my_app->querySubObject("Documents");
    4.  
    5. //Open newDocName
    6. QVariant filename(newDocName);
    7. QVariant confirmconversions(false);
    8. QVariant readonly(false);
    9. QVariant addtorecentfiles(false);
    10. QVariant passworddocument("");
    11. QVariant passwordtemplate("");
    12. QVariant revert(false);
    13. QAxObject* doc = my_docs->querySubObject("Open(const QVariant&, const QVariant&,const QVariant&, const QVariant&, const QVariant&, const QVariant&,const QVariant&)", filename,confirmconversions, readonly, addtorecentfiles, passworddocument, passwordtemplate, revert);
    14.  
    15. //Pull out active document object
    16. QAxObject* active_doc = my_app->querySubObject("ActiveDocument");
    17.  
    18. QVariant newFileName(fileNameString);
    19. QVariant fileFormat(10); //Saving as filtered html
    20. QVariant LockComments(false);
    21. QVariant Password("");
    22. QVariant recent(true);
    23. QVariant writePassword("");
    24. QVariant ReadOnlyRecommended(false);
    25.  
    26. active_doc->querySubObject("SaveAs(const QVariant&, const QVariant&,const QVariant&, const QVariant&, const QVariant&, const QVariant&,const QVariant&)", newFileName, fileFormat, LockComments, Password, recent, writePassword, ReadOnlyRecommended);
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Remove word microsoft only chars by unicode
    By patrik08 in forum Qt Programming
    Replies: 0
    Last Post: 27th May 2008, 08:30
  2. invoking microsoft word from qt
    By omprakash in forum Qt Programming
    Replies: 2
    Last Post: 31st October 2007, 20:43

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.