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
  #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
  #2  
Old October 30th, 2004, 01:26 AM
Shauna Kelly
external usenet poster
 
Posts: n/a
Default

Hi Jason

Let's step back a bit here and look at the problem, and not the solution.

First, what do you have now? You have a text file produced from another
souce. So presumably the whole document is in Normal style. Every so often
the word "Recommendations" appears, and every so often the word "Discussion"
appears. There are paragraphs of text between the "Recommendations" and
"Discussion". What do those paragraphs look like? Have been numbered
manually (eg with hard-type text 1, 1.1, 1.2, 2, 2.1, 2.2 etc)?

Second, what do you want to end up with? Automatic paragraph numbering on
every paragraph? In what format? And how should the "Recommendations" and
"Discussions" paragraphs be numbered?

Write back and let us know what your text file looks like, and what you want
to end up with. Then we can think about the best solution.

Hope this helps.

Shauna Kelly. Microsoft MVP.
http://www.shaunakelly.com/word


"Jason L" wrote in message
...
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,
itwasasafebet.Ifoundoutlater
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



  #3  
Old November 1st, 2004, 07:19 PM
Jason L
external usenet poster
 
Posts: n/a
Default

Shauna,

Thanks for responding. The file is actually from Excel. The users number
chunks of text in an excel file, and then I take this excel file and merge it
into this merge document. This works out well for them, except that the
areas they have numbered are unformatted and quite unattractive. With my
initial macro I managed to get the numbered areas to reformat using a List
Number style, but each numbered list continued from the previous list. I
need the numbered lists to begin at one after the word Recommendations or
Discussions. I was going to use Outline style, and use Recommendations and
Discussions as heading 1, but this proved to be rather difficult. I also
used section breaks after each heading, but the problem there is that the
page numbering got messed up (after page 2, each consecutive page number
repeated 2).

I want to end up with automatic numbering for each section of text that has
numbers already. These sections will need to restart numbering anytime after
the headings Recommendations or Discussions. The numbering continues until
the unformatted numbered text runs out.

I have been discussing this with Helmut Weber, if you want some more
background. Here is the link to that discussion: http://tinyurl.com/492de

TIA,
Jason


"Shauna Kelly" wrote:

Hi Jason

Let's step back a bit here and look at the problem, and not the solution.

First, what do you have now? You have a text file produced from another
souce. So presumably the whole document is in Normal style. Every so often
the word "Recommendations" appears, and every so often the word "Discussion"
appears. There are paragraphs of text between the "Recommendations" and
"Discussion". What do those paragraphs look like? Have been numbered
manually (eg with hard-type text 1, 1.1, 1.2, 2, 2.1, 2.2 etc)?

Second, what do you want to end up with? Automatic paragraph numbering on
every paragraph? In what format? And how should the "Recommendations" and
"Discussions" paragraphs be numbered?

Write back and let us know what your text file looks like, and what you want
to end up with. Then we can think about the best solution.

Hope this helps.

Shauna Kelly. Microsoft MVP.
http://www.shaunakelly.com/word


"Jason L" wrote in message
...
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,
itwasasafebet.Ifoundoutlater
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




  #4  
Old November 1st, 2004, 08:37 PM
Shauna Kelly
external usenet poster
 
Posts: n/a
Default

Hi Jason

I have been discussing this with Helmut Weber, if you want some more

background. Here is the link to that discussion: http://tinyurl.com/492de


If this issue is being discussed in another newsgroup, then it may be
appropriate to confine the discussion there.

Shauna

Shauna Kelly. Microsoft MVP.
http://www.shaunakelly.com/word


"Jason L" wrote in message
...
Shauna,

Thanks for responding. The file is actually from Excel. The users number
chunks of text in an excel file, and then I take this excel file and merge
it
into this merge document. This works out well for them, except that the
areas they have numbered are unformatted and quite unattractive. With my
initial macro I managed to get the numbered areas to reformat using a List
Number style, but each numbered list continued from the previous list. I
need the numbered lists to begin at one after the word Recommendations or
Discussions. I was going to use Outline style, and use Recommendations
and
Discussions as heading 1, but this proved to be rather difficult. I also
used section breaks after each heading, but the problem there is that the
page numbering got messed up (after page 2, each consecutive page number
repeated 2).

I want to end up with automatic numbering for each section of text that
has
numbers already. These sections will need to restart numbering anytime
after
the headings Recommendations or Discussions. The numbering continues
until
the unformatted numbered text runs out.

I have been discussing this with Helmut Weber, if you want some more
background. Here is the link to that discussion: http://tinyurl.com/492de

TIA,
Jason


"Shauna Kelly" wrote:

Hi Jason

Let's step back a bit here and look at the problem, and not the solution.

First, what do you have now? You have a text file produced from another
souce. So presumably the whole document is in Normal style. Every so
often
the word "Recommendations" appears, and every so often the word
"Discussion"
appears. There are paragraphs of text between the "Recommendations" and
"Discussion". What do those paragraphs look like? Have been numbered
manually (eg with hard-type text 1, 1.1, 1.2, 2, 2.1, 2.2 etc)?

Second, what do you want to end up with? Automatic paragraph numbering on
every paragraph? In what format? And how should the "Recommendations" and
"Discussions" paragraphs be numbered?

Write back and let us know what your text file looks like, and what you
want
to end up with. Then we can think about the best solution.

Hope this helps.

Shauna Kelly. Microsoft MVP.
http://www.shaunakelly.com/word


"Jason L" wrote in message
...
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,
itwasasafebet.Ifoundoutlater
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 12:20 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.