View Single Post
  #4  
Old November 1st, 2004, 07: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