Hi Alfonso,
Don't try to handle this by inserting and deleting items individually.
Use the Find/Replace feature to replace all paragraph marks with the
combination </p><p>.
In the Replace dialog, you would put ^p in the Find What box and put
</p><p> in the Replace With box, and hit Replace All. Then you'll just
have to insert the <p> before the first paragraph and delete the extra
<p> at the end of the document.
In a macro, the code would look like this:
Sub foo()
Dim oRg As Range
Set oRg = ActiveDocument.Range
With oRg.Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = "^p"
.Replacement.Text = "</p><p>"
.Format = False
.Forward = True
.Wrap = wdFindContinue
.MatchWildcards = False
.Execute Replace:=wdReplaceAll
End With
Set oRg = ActiveDocument.Range
' insert tag at beginning of doc
oRg.InsertBefore "<p>"
' remove extra tag at end of doc
' (this works because the only ^p
' left in the doc is the one at
' the end)
With oRg.Find
.Text = "</p><p>^13"
.Replacement.Text = "</p>^13"
' all other settings stay as before
.Execute Replace:=wdReplaceAll
End With
End Sub
--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
>Hello Everybody,
>I am making a macro to convert word pararaphs into html paragraphs.
[quoted text clipped - 17 lines]
>
>alfonso gonzales
Klaus Linke - 23 Feb 2005 02:13 GMT
Hi Jay,
I wouldn't use ^13 in "Replace with"... it often inserts a character that looks like a paragraph mark, but doesn't work like one (= doesn't store the style and paragraph formatting). And the last paragraph mark even stores section and document formatting.
It might work, but just seems a bit risky ;-)
BTW, a wildcard replacement
Find what: ([!^13]@)(^13)
Replace with: <p>\1</p>\2
would also insert the tags.
Regards,
Klaus
> Hi Alfonso,
>
[quoted text clipped - 65 lines]
> >
> >alfonso gonzales