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 / May 2006

Tip: Looking for answers? Try searching our database.

How can I automate my Macro?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
MichaelB - 10 May 2006 19:35 GMT
Hello,

I have the below Marco which will reformat a selected section of text,
clearing the format and then implementing new formatting. This works fine but
I am finding that I have tens of thousands of modifications within one
document that must be made. Is it possible to have this macro search for a
desired string of text (like “Justification:”), then automatically select the
string and following text to the next hard return (¶) and then perform the
reformatting options? It would be nice to automate this process for going
through 589 pages searching for this is getting very tedious.

Any help would be greatly appreciated.
Mike

Sub fix_Paragraph1_Font_Bold()
'
' Macro to clear all formatting on selected text and then re-implement the
‘ proper paragraph 1 style with the first section (up to the “:”) being set to
‘ paragraph 1 + Bold Font
'
   Selection.ClearFormatting
   Selection.ClearFormatting
   Selection.Style = ActiveDocument.Styles("Paragraph 1")
   Selection.HomeKey Unit:=wdLine
   Selection.Find.ClearFormatting
   With Selection.Find
       .Text = "*:"
       .Replacement.Text = ""
       .Forward = True
       .Wrap = wdFindContinue
       .Format = False
       .MatchCase = False
       .MatchWholeWord = False
       .MatchAllWordForms = False
       .MatchSoundsLike = False
       .MatchWildcards = True
   End With
   Selection.Find.Execute
   Selection.Font.Bold = wdToggle
   Selection.HomeKey Unit:=wdLine
End Sub
Charles Kenyon - 11 May 2006 00:31 GMT
Before you go too far with writing macros to handle formatting, look into
Styles.
Signature

Charles Kenyon

Word New User FAQ & Web Directory: http://addbalance.com/word

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide

See also the MVP FAQ: http://word.mvps.org/FAQs/ which is awesome!

My criminal defense site: http://addbalance.com
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.

> Hello,
>
[quoted text clipped - 40 lines]
>    Selection.HomeKey Unit:=wdLine
> End Sub
MichaelB - 11 May 2006 16:36 GMT
Charles,

This is one the problems I am having, there are several styles being used
(for this is a document which expands several Word versions) which I am
attempting to cleaning up, Notice the clear formatting. I am then trying to
standardize the text into the Paragraph 1 style with the first part (up to
the “:”) being bolded. I just need help in getting this wrapped into a loop
which will automate the tasks. I need to find all occurrences of specific
text then highlight the entire paragraph, remove any formatting that exists
and then implement the proper style.

Again any help would be greatly appreciated.
Mike

> Before you go too far with writing macros to handle formatting, look into
> Styles.
[quoted text clipped - 42 lines]
> >    Selection.HomeKey Unit:=wdLine
> > End Sub
 
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.