Results 1 to 5 of 5

Thread: Insert picture into MS Word Document

  1. #1
    Join Date
    Oct 2012
    Posts
    5
    Thanks
    2
    Qt products
    Qt4 Qt/Embedded

    Default Insert picture into MS Word Document

    How can I insert picture into MS Word Document?
    I tried this, but it didnt work:
    Qt Code:
    1. QAxObject* WordApplication = new QAxObject("Word.Application");
    2.  
    3. QAxObject* WordDocuments = WordApplication->querySubObject("Documents()");
    4. QAxObject* NewDocument = WordDocuments->querySubObject("Add()");
    5. WordApplication->setProperty("Visible", true);
    6.  
    7. QAxObject* ActiveDocument = WordApplication->querySubObject("ActiveDocument()");
    8.  
    9. QAxObject *inlineShapes = ActiveDocument->querySubObject("InlineShapes()");
    10. QAxObject *addPicture = inlineShapes->querySubObject("AddPicture(QString&)","./add.png");
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Insert picture into MS Word Document

    It didn't work
    Hardly descriptive is it? What did it do? Why do you think it didn't work? Error messages?

    You are using a relative path to the file. Be very sure you know where the current work directory of the running application is.

  3. #3
    Join Date
    Oct 2012
    Posts
    5
    Thanks
    2
    Qt products
    Qt4 Qt/Embedded

    Default Re: Insert picture into MS Word Document

    Quote Originally Posted by ChrisW67 View Post
    Hardly descriptive is it? What did it do? Why do you think it didn't work? Error messages?

    You are using a relative path to the file. Be very sure you know where the current work directory of the running application is.
    Sorry, ofcouse (for my bad english too).
    Now Word is runing with program, document creating and nothing more, pure empty list.
    In other words works all except picture insert And no error messages.
    Yes, in that I'm sure)

  4. #4
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Insert picture into MS Word Document

    AddPicture has four arguments, perhaps you need to provide null QVariants for the unspecified optional arguments. Cannot try it myself, have no Word.

  5. #5
    Join Date
    Oct 2012
    Posts
    5
    Thanks
    2
    Qt products
    Qt4 Qt/Embedded

    Default Re: Insert picture into MS Word Document

    Quote Originally Posted by ChrisW67 View Post
    AddPicture has four arguments, perhaps you need to provide null QVariants for the unspecified optional arguments. Cannot try it myself, have no Word.
    Thank you for your trying to help me!
    But this
    Qt Code:
    1. QAxObject* WordApplication = new QAxObject("Word.Application");
    2.  
    3. QAxObject* WordDocuments = WordApplication->querySubObject("Documents()");
    4.  
    5. QAxObject* NewDocument = WordDocuments->querySubObject("Add()");
    6.  
    7. WordApplication->setProperty("Visible", true);
    8.  
    9. QAxObject* ActiveDocument = WordApplication->querySubObject("ActiveDocument()");
    10.  
    11. QAxObject *inlineShapes = ActiveDocument->querySubObject("InlineShapes()");
    12.  
    13. QAxObject *addPicture = inlineShapes->querySubObject("AddPicture(QString, QVariant, QVariant, QVariant)",
    14. "D:\\Projects\\ApproximateView\\ApproximateView\\add.png",0,0,0);
    To copy to clipboard, switch view to plain text mode 
    Still dont wanna work

Similar Threads

  1. Replies: 10
    Last Post: 11th June 2012, 09:16
  2. Replies: 4
    Last Post: 13th January 2010, 17:05
  3. How to insert an animated picture (GIF) in a QLabel
    By AngiSad in forum Qt Programming
    Replies: 1
    Last Post: 13th January 2010, 16:31
  4. can Qt open MS word document?
    By coder1985 in forum Qt Programming
    Replies: 1
    Last Post: 25th December 2007, 14:34
  5. Replies: 10
    Last Post: 24th August 2006, 09:35

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.