CoderSource.net
Search
parsing an ms-word by an addIn
Started by tcp at 05-25-2006 2:30 AM. Topic has 2 replies.

Print Search « Previous Thread
   05-25-2006, 2:30 AM
tcp is not online. Last active: 7/21/2006 10:46:40 AM tcp

Top 10 Posts
Joined on 05-21-2006
Posts 7
Hmm [^o)] parsing an ms-word by an addIn

Hi all,

I created an addin which inserts a button into the ms-word but I need to parse the text of an active ms-word document and then to replase some of its words.

How can I read/retrieve the documents text? AND when a specific word is found, by my parser, How can I replase it???

Is it possible to get text by its format; for example, to get all the text in the document which is in Bold or Italic letters or for example is with font "Times" ???

Pleas help meCrying [:'(] Im having a hell of a tim with it .


   Report 
   05-29-2006, 7:04 AM
Mukesh is not online. Last active: 7/6/2006 5:51:08 AM Mukesh

Top 75 Posts
Joined on 05-29-2006
Posts 1
Idea [I] Re: parsing an ms-word by an addIn
  Hi

With the help of Automation you can solve your problem.


 Click ClassWizard on the View menu (or press CTRL+W). Select the Automation tab. Click Add Class and choose "From a type library." Navigate to select the object library for the application you wish to automate (for this example, if you are automating Word 97, choose the Microsoft word 8.0 Object Library; the default location is C:\Program Files\Microsoft Office\Office\word8.olb) or word9.olb 

Once you have selected the appropriate object libraryor wrapper class, click Open. Select all or specifically _Font ,_Document  classes in the Confirm Classes list, and then click OK.

NOTE: The list box in the Confirm Classes dialog box contains all of the IDispatch interfaces (which are virtually identical to classes) in the Microsoft Word type library. In the lower half of the dialog box you will see that an Implementation file named Word8.cpp contains generated class wrappers derived from ColeDispatchDriver(), and the appropriate declaration header file is named Word8.h. (For Word 2002 and Word 2003, the files are named Word.cpp and Word.h.)

Click OK to close the MFC ClassWizard dialog box.


Add the following code to the CAutoProjectApp::InitInstance() function, which loads and enables the COM services library:

BOOL CAutoProjectApp::InitInstance() { if(!AfxOleInit()) // Your addition starts here { AfxMessageBox("Could not initialize COM dll"); return FALSE; } // End of your addition AfxEnableControlContainer(); . . . }

Add the following line to the #include statements at the top of the AutoProject.cpp program file:

#include

Add the include statement for word8.h after the include statement for stdafx.h at the top of the AutoProjectDlg.cpp program file:

#include "stdafx.h" #include "word8.h" // word.h in the case of Word 2002 and Word 2003.

now you can use wrraper class functions to  find out occurrence of italic word with the help of GetItalic();
try and mail me further difficulties if you have.

Mukesh


   Report 
   06-12-2006, 6:50 AM
tcp is not online. Last active: 7/21/2006 10:46:40 AM tcp

Top 10 Posts
Joined on 05-21-2006
Posts 7
Re: parsing an ms-word by an addIn
Hi Mukesh,

Im sorry for the delay;

Idid not succeeded yet. As I understand from your explanations you want me to start a new project but I already have an addin which is hosted by the ms-word. The addidn inserts a command button into the MSW and sinks its events (the events of the command button).

When the button is clicked Im back in the CConnect class, there I have an IDispatch *pApplication.

Somehow, I cant get the document object. I can only use the: pApplication->QueryInterface(...); GetProperty(...); and SetProperty(...);

Of course, I can use: pApplication->AddRef(), pApplication->GetIDsOfNames(),

pApplication->GetTypeInfo(), ...

pApplication->Invoke(), ...

(*) I dont use MFC, I use ATL.

I get a fatal error C1083 whenever I try to include Word.h or word8.h ... Thus, i dont know what to do.

????

--------------------

I hope, you know how to help me now, because it seems like you are the only one who knows anything.

Best regards,

tcp.


   Report 
Codersource.Net » Programming » C++ Programming » parsing an ms-word by an addIn

MENU
Home
MFC 
C++
.Net
WIN32
Programming
Forum
My Articles
Welcome to Codersource.Net Login | Register | Faq  

Google
 

NOTES:


Thanks for visiting our CoderSource.net. This site will be improved with more articles. Interested visitors can also submit their articles through the Submit Article link.Your article will also be published after due consideration by the editor. 

© Copyright 2003. All rights on content reserved by CoderSource.net. Contact    About Us