How to initialize Range object with Current page 
Author Message
 How to initialize Range object with Current page

Automation in MFC
=================

Hello all,
I want to get the words of the MS Word document
that is currently viewed by the user and store
it in the range object.
Is there any possible way of getting the words
of the page viewed by the user, say he may viewing
a speific page number 7.
Right now i am using MFC with "msword9.olb"(Word 2000)
Any Idea will be highly appriciated.

Thanks in advance,
alex



Mon, 30 May 2005 16:53:10 GMT  
 How to initialize Range object with Current page
Hi Alex,

If the selection is in the page being viewed.

Selection.Bookmarks("\page").Range will return the text of that page.

Please post any response to the newsgroups for the benefit of others who may
also be following the thread.

Hope this helps,
Doug Robbins - Word MVP

Quote:
> Automation in MFC
> =================

> Hello all,
> I want to get the words of the MS Word document
> that is currently viewed by the user and store
> it in the range object.
> Is there any possible way of getting the words
> of the page viewed by the user, say he may viewing
> a speific page number 7.
> Right now i am using MFC with "msword9.olb"(Word 2000)
> Any Idea will be highly appriciated.

> Thanks in advance,
> alex




Mon, 30 May 2005 18:04:23 GMT  
 How to initialize Range object with Current page

Thanks Doug Robbins ,
Is there any equivalent comman in MFC for this :

Selection.Bookmarks("\page").Range

thanks.



Tue, 31 May 2005 21:07:34 GMT  
 How to initialize Range object with Current page
For the purpose of those who follow this thread...........
=========================================================

_Application app;
Documents docs;
_Document doc;
Bookmarks bms;
Bookmark bm;
Range rng;

COleVariant opt((long)DISP_E_PARAMNOTFOUND, VT_ERROR);
app.CreateDispatch("Word.Application");
app.SetVisible(TRUE);
docs = app.GetDocuments();
doc = docs.Open(COleVariant("1.doc"), &opt, &opt, &opt,
                &opt, &opt, &opt, &opt,
                &opt, &opt, &opt, &opt);
bms = doc.GetBookmarks();
bm = bms.Item(COleVariant("Page"));
rng = bm.GetRange();

rng.ReleaseDispatch();  
bm.ReleaseDispatch();
bms.ReleaseDispatch();
doc.ReleaseDispatch();
app.Quit(&opt, &opt,&opt);
=========================================================
This code works well for all huge docs
except for the condition that the
caret position should be on the page
where we move the mouse.
If my caret position is on 3rd page and
i use the scroll bar and move to 7th page
then no result.
Still i do not have a complete idea how
to get words of the current page viewed by user.

bye
alex



Tue, 07 Jun 2005 14:58:34 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. How to initialize Range with current Page

2. Another question about range objects... inserting page break

3. Very simple Range question - beggining the range on 3rd page onwards

4. VBA EXCEL97: How to get the range from a chart into a range object

5. printer object - Skipping the current page

6. How can I set a Range from Page X to Page Y

7. Range object, Selection object

8. Using the Range object in Excel Object Library 9.0

9. date range to current date at specific time syntax question

10. Q:get current date and then create date range

11. SendObject - controlling the range of pages in the report

12. Printing Specific or Range of Pages

 

 
Powered by phpBB® Forum Software