A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Word » Page Layout
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Help with searching/replacing numbered lists



 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old October 27th, 2004, 03:19 PM
Jason L
external usenet poster
 
Posts: n/a
Default Help with searching/replacing numbered lists

Hi, I am using Word 2002 on Windows 2000. This is a long query. Thanks for
your patience.

I am trying to create a macro that searches through a document and finds an
unformatted numbered or lettered list and replace these unformatted lists
(this is text merged from another source) with Word formatting (e.g. from the
bullets and numbering lists). There are several lists in this document, but
most of them number up to maybe 20. There is text between each list, but my
main problem now is that the numbered or alpha list does continual numbering
or lettering, which is not what I want. So I devised to insert continuous
section breaks before each numbered lists by using the following code to find
the word Recommendations: and insert a section break after it.

Const LookFor As String = "Recommendations:"
'
With ActiveDocument.Content.Find
.ClearFormatting
.Text = LookFor
With .Font
.Name = "Times New Roman"
.Bold = True
.Size = 11
End With
Do While .Execute
With .Parent
.Collapse wdCollapseEnd
.InsertBreak wdSectionBreakContinuous
.Collapse wdCollapseEnd


End With
Loop
End With
Since most lists begin at this word, it was a safe bet. I found out later
they also need the numbered lists to start at one after the word Discussion
(addtional question - how do I also have the above macro look for Discussion
and insert a section break?).

So here is the code I use thus far to find the unformatted numbered lists
and format them:

With Selection.Find
.Text = "(^13)[0-9]{1,}.[^32^s^t]@"
.Replacement.Text = "\1^+"
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
End With

Selection.Find.Execute Replace:=wdReplaceAll


Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
Selection.Find.Replacement.Style = ActiveDocument.Styles("List Number")

With Selection.Find
.Text = "^+@"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
End With
Selection.Find.Execute Replace:=wdReplaceAll

Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "^+"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
End With
Selection.Find.Execute Replace:=wdReplaceAll

There might be some redundancy here, but the main idea was to repalce the
number,period and any space following it with an em dash. I would then use
the em dash as a placeholder to reformat the entire list. This worked well
with the section break idea above, but when the page numbers increase beyond
2, each additional page number is 2.

My most recent solution is to make Recommendations and Discussion Header 6
styles. Modify the styles and add outline numbering, except make sure the
first level has no number, but each following level contains a number. For
some reason this is not working either.

Okay, I am essentially hoping to get some assistance or direction on what is
the best option for me. Is there a way to fix the page numbering after my
macro has inserted the section breaks for re-numbering purposes? Or shoud I
head in the direction of making the headings Recommendations and Discussion
Level 1 headers in the beginning of an outlined numbered list?

TIA,
Jason
 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Styles, Numbered Lists and IncludeText JBC Formatting Long Documents 3 September 10th, 2004 03:08 PM
Customized numbered lists DAW Page Layout 3 June 14th, 2004 09:17 AM
Numbered Lists Mary Lee Page Layout 1 May 7th, 2004 11:57 AM
Get Rid of Tabs in Numbered Lists Ellen Formatting Long Documents 2 May 4th, 2004 02:19 PM


All times are GMT +1. The time now is 02:31 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.