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 / March 2007

Tip: Looking for answers? Try searching our database.

Word VBA Macro Find Text

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
spovolny@gmail.com - 27 Mar 2007 17:04 GMT
I KNOW Microsoft Word has a find function - but I'm looking for a way
to find all occurrences of a string in a document.  I set up a text
box to enter the string (for example "abcd") and a button to "Find
Now".  It will find the first occurrence, but I would like to know how
to get the number of all occurrences of "abcd" throughout the
document.  Sorry this is a newbie question - I don't know VBA too well
yet.  Thanks in advance to anyone who can help.
Steve
Greg Maxey - 27 Mar 2007 17:29 GMT
You don't need a macro for this.  Instead of using Find use Replace.
Find "abcd" and replace with "abcd" click "Replace All."  Word will
tell you how many times it performs the replacement.

On Mar 27, 12:04 pm, spovo...@gmail.com wrote:
> I KNOW Microsoft Word has a find function - but I'm looking for a way
> to find all occurrences of a string in a document.  I set up a text
[quoted text clipped - 4 lines]
> yet.  Thanks in advance to anyone who can help.
> Steve
spovolny@gmail.com - 27 Mar 2007 18:49 GMT
> You don't need a macro for this.  Instead of using Find use Replace.
> Find "abcd" and replace with "abcd" click "Replace All."  Word will
[quoted text clipped - 10 lines]
> > yet.  Thanks in advance to anyone who can help.
> > Steve

Thanks -
I do know how to do this and get the number of replacements - is there
a way to store this number in a variable?  When I ran it as a recorded
macro, it doesn't record the number of replacements made which is the
number I'm looking for.  Any ideas?
Greg Maxey - 27 Mar 2007 20:52 GMT
Well I have an AddIn that I posted on my website a year or so ago that
provided a count of items found.  You could adapt it to the write the
count to a document variable:

http://gregmaxey.mvps.org/Find_it_tool_bar.htm

On Mar 27, 1:49 pm, spovo...@gmail.com wrote:

> > You don't need a macro for this.  Instead of using Find use Replace.
> > Find "abcd" and replace with "abcd" click "Replace All."  Word will
[quoted text clipped - 16 lines]
> macro, it doesn't record the number of replacements made which is the
> number I'm looking for.  Any ideas?
 
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.