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 / September 2005

Tip: Looking for answers? Try searching our database.

Need help with simple macro

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Erik - 07 Sep 2005 16:35 GMT
I need a macro that will loop thru a word document and look for words with a
certain font size (say 18).  Then change the style of those words to Heading
2, and 'bulletize' the word using a numbered list.  I'm having problems
getting it to look at individual words.

Thanks in advance for any help.
Edward Thrashcort - 07 Sep 2005 17:45 GMT
Supposing there is more than one such work on a single line?
How do you plan to deal with that?

Why not use find and replace?

Eddie

> I need a macro that will loop thru a word document and look for words
> with a certain font size (say 18).  Then change the style of those words
> to Heading 2, and 'bulletize' the word using a numbered list.  I'm having
> problems getting it to look at individual words.
>
> Thanks in advance for any help.
Erik - 07 Sep 2005 18:48 GMT
Just looking for the easiest way to automate it.  Can you automate a
find/replace?

> Supposing there is more than one such work on a single line?
> How do you plan to deal with that?
[quoted text clipped - 9 lines]
> >
> > Thanks in advance for any help.
Doug Robbins - 07 Sep 2005 19:41 GMT
Selection.HomeKey wdStory
Selection.Find.ClearFormatting
Selection.Find.Font.Size = 18
With Selection.Find
   Do While .Execute(FindText:="*", MatchWildcards:=True,
Wrap:=wdFindContinue, Forward:=True) = True
       Selection.Paragraphs(1).Style = "Heading 2"
       Selection.Paragraphs(1).Range.Select
       Selection.Collapse wdCollapseEnd
   Loop
End With

The bulletizing should be taken care of by the definition of the style.

Signature

Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

> Just looking for the easiest way to automate it.  Can you automate a
> find/replace?
[quoted text clipped - 14 lines]
>> >
>> > Thanks in advance for any help.
Erik - 07 Sep 2005 22:14 GMT
Thanks Doug.  That seems to work, but it appears to get stuck in an endless
loop, and I have to terminate Word to get out of it.

> Selection.HomeKey wdStory
> Selection.Find.ClearFormatting
[quoted text clipped - 28 lines]
> >> >
> >> > Thanks in advance for any help.
Bill Foley - 07 Sep 2005 17:45 GMT
The simple fix might have already been done, but if you change the path of
your Startup folder, you need to close Word then re-open Word before this
template toolbar will show up.

Signature

Bill Foley
www.pttinc.com
Microsoft PowerPoint MVP
Microsoft Office Specialist Master Instructor

> I need a macro that will loop thru a word document and look for words with a
> certain font size (say 18).  Then change the style of those words to Heading
> 2, and 'bulletize' the word using a numbered list.  I'm having problems
> getting it to look at individual words.
>
> Thanks in advance for any help.
Bill Foley - 07 Sep 2005 18:12 GMT
My bad, wrong post!

Signature

Bill Foley
www.pttinc.com
Microsoft PowerPoint MVP
Microsoft Office Specialist Master Instructor

> The simple fix might have already been done, but if you change the path of
> your Startup folder, you need to close Word then re-open Word before this
[quoted text clipped - 8 lines]
> >
> > Thanks in advance for any help.
 
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.