find and replace for a bullet list to html tagged style list


L

Liam

I'm wanting a macro to find instances of bullet lists, and replace it
with a html tagged list. Please see below for an example:

**my_doc.docx**
....

text,text,text
My bullet list:
• List point one
• List point two
Some more text here.

....

A find and replace resulting in

....

text,text,text
My bullet list:
<ul>
<li>List point one</li>
<li>List point two</li>
</ul>
Some more text here.
....

Does anyone know of a way to do this? I've tried looking for the
bullet characters; doesn't work as it's formatting. Tried looking for
lines with style "List bullet" and any other lists i can find; doesn't
work, I don't know why.
 
Ad

Advertisements

L

Liam

I'm wanting a macro to find instances of bullet lists, and replace it
with a html tagged list. Please see below for an example:

**my_doc.docx**
...

    text,text,text
    My bullet list:
       • List point one
       • List point two
    Some more text here.

...

A find and replace resulting in

...

    text,text,text
    My bullet list:
    <ul>
    <li>List point one</li>
    <li>List point two</li>
    </ul>
    Some more text here.
...

Does anyone know of a way to do this? I've tried looking for the
bullet characters; doesn't work as it's formatting. Tried looking for
lines with style "List bullet" and any other lists i can find; doesn't
work, I don't know why.

Anyways I found another script to iterate through each line of the
document and add to a counter. Do you know if there would be a way to
append to the found paragraph <li> tags on either end... something
like below???


Sub FindBullet()
Dim oPara As Word.Paragraph
Dim count As Integer

count = 0
Selection.WholeStory
With Selection
For Each oPara In .Paragraphs
If oPara.Range.ListFormat.ListType = _
WdListType.wdListBullet Then

count = count + 1

# from here down it gets shaky!!!

With ActiveDocument.Range.Find
..Text = #How do i convert the oPara to a string here?!?
..Forward = True
..Wrap = wdFindContinue
..Format = False
..MatchCase = True
..MatchWholeWord = False
..MatchWildcards = False
..MatchSoundsLike = False
..MatchAllWordForms = False

..ClearFormatting
With .replacement
..ClearFormatting
..Text = # how do i specify this is where i want the "<li>" & oPara &
"</li>"
End With
..Execute Replace:=wdReplaceAll

End If
Next
End With
'Gives you the count of bullets in a document
MsgBox count & " replacements"
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top