wxAutomationObject(opening a existing doc problem)

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
mohan
Experienced Solver
Experienced Solver
Posts: 61
Joined: Wed May 07, 2008 9:55 am

wxAutomationObject(opening a existing doc problem)

Post by mohan » Fri Oct 31, 2008 7:21 am

Hi All,
This is my code for opening the existing doc.It is displaying the word application but not opening the existing doc.

wxAutomationObject objectWordApp;
wxString docPath = "C:\\testword.doc";
objectWordApp.CreateInstance("Word.Application");
objectWordApp.PutProperty("Visible","1");
objectWordApp.CallMethod("Documents.Open",docPath);

Thanks,
Mohan.

timg
Earned some good credits
Earned some good credits
Posts: 148
Joined: Mon Jan 23, 2006 6:52 pm

Post by timg » Fri Oct 31, 2008 9:21 am

Your code works for me. Are you sure the document exists?

mohan
Experienced Solver
Experienced Solver
Posts: 61
Joined: Wed May 07, 2008 9:55 am

Post by mohan » Fri Oct 31, 2008 9:47 am

Yes It is existing and I am using MS WORD 2007.It is still showing a blank word application without document.

timg
Earned some good credits
Earned some good credits
Posts: 148
Joined: Mon Jan 23, 2006 6:52 pm

Post by timg » Fri Oct 31, 2008 5:21 pm

I only have Word 2003. It works with that.

ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 3568
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Post by ONEEYEMAN » Fri Oct 31, 2008 10:08 pm

Hi,
Can you trace which call is failing?

Thank you.

vsp
Knows some wx things
Knows some wx things
Posts: 35
Joined: Mon Feb 21, 2005 12:52 pm

Post by vsp » Mon Nov 03, 2008 7:53 am

The same code is working fine for me too.

While doing this I did a mistake. The default file office 2007 creats docx.

so I have just changed the extension. In your case if you have created a doc file , then the code works fine too with just doc extension.

wxString docPath = "C:\\testword.doc";

wxAutomationObject objectWordApp;
wxString docPath = "C:\\testword.docx";
objectWordApp.CreateInstance("Word.Application");
objectWordApp.PutProperty("Visible","1");
objectWordApp.CallMethod("Documents.Open",docPath);

Post Reply