Log in

View Full Version : finding numbered level 1 parqagraphs



Joe Ury
08-25-2013, 04:39 AM
Eventually I want to add an html tag to the beginning of each paragraph so when I convert a word document to html I can add the numbered html tags. So the first paragraph would start: 1. <a name="para1">. Below is as close as I can get. I don't think it'll pick out only level 1 numbered paragraphs as I wish it to and also the paragraph number isn't inserted into the html tag.

Hints examples would be most welcome. T

Thanking you,

Joe



ActiveDocument.ConvertNumbersToText
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "^p^#^#^#^#."
.Replacement.Text = "^&<a name=""#"">"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
With Selection.Find
.Text = "^p^#^#^#."
.Replacement.Text = "^&<a name=""#"">"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
With Selection.Find
.Text = "^p^#^#."
.Replacement.Text = "^&<a name=""#"">"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
With Selection.Find
.Text = "^p^#."
.Replacement.Text = "^&<a name=""#"">"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll

Doug Robbins
08-25-2013, 05:41 PM
Seems to me that you could do a single wildcard find replace using

.Text = "(^13[0-9]{1,4}.)"

and

.Replacement.Text = "\1<a name = ""#"">"

Joe Ury
08-26-2013, 02:20 AM
G'day Doug thanks for this - it works a treat. Would you confirm that given a number of word files created by different people with most but not all paragraphs numbered in each document there is no way to consistently mark only those numbered paragraphs. I was looking at trying to spot only those that were style=paralevel1 but not only can I get that to work but it seems, though I'm not sure, that the level may differ among different files.

Thnaks again,

Joe