Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / July 2005

Tip: Looking for answers? Try searching our database.

VBA Word 2002: how to get the document sentence/word # for the current (collapsed) insertion point

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Avraham Makeler - 17 Jul 2005 21:03 GMT
Hi all,

VBA Word 2002:
Anybody know how to get the document sentence number for the current
(collapsed) insertion point?

I need to display some sort of progress of running a processing routine on a
document. I am not processing on a sentence-by-sentence basis; rather the
processing searches for highlited areas, and so when a hit is made I don't
know where I am in the document. So I need some way of getting some sort of
umber to tell me where I am. Btw, this doesn't have to be the sentence
number: this could also be Word #, Line #, Paragraph # (less good). I
couldn't find any "return index number" functions in the API.

tia

Avraham Makeler
Jay Freedman - 17 Jul 2005 22:09 GMT
>Hi all,
>
[quoted text clipped - 13 lines]
>
>Avraham Makeler

Hi Avraham,

Look at http://word.mvps.org/FAQs/MacrosVBA/GetIndexNoOfPara.htm,
which shows how to get the index number of the current member of any
collection that has a .Count property.

--
Regards,
Jay Freedman
Microsoft Word MVP         FAQ: http://word.mvps.org
Avi Mak - 18 Jul 2005 07:37 GMT
Thanks, Jay.

You managed to answer faster than I could jump in and answer my own
question. I had made one further search and found the following answer:

 ActiveDocument.Range(0, Selection.Range.End).Sentences­.Count

(in the name of Doug Robbins - Word MVP)

which is the same idea as the answer you refer to.

I am a programmer of many years experience, but a relative beginner at
VBA. I am surprised that obtaining a sentence/para/word index index is
so convoluted. I would guess that this solution requires a lot of CPU
time, and indeed this seems to be borne out in practice. I have written
a progress bar, and it severely slows down the processing of the
document. It runs a lot faster without the progress bar, but I DO want
the progress bar. Ok, so I decide to recalculate and display it only
every 5 or 10 times, so that helps - just makes it look a bit jumpy.

Thanks.

Avraham.
Avi Mak - 18 Jul 2005 11:01 GMT
Ok, I tried it. It is just tooo slow - it takes longer than the time
needed to process the document ...! The PCs I have at my place of work
are too slow to take this. (The company buys cheapo whenever it can -
low MegaHertz, Narrow buses, small caches, etc. My own PC at home is a
2.8GHz FULL. And it blazes. But I am not at home; I am at work.)

Anybody have any better ideas how to get the line/para/sentence?

Avraham.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.