Question

I'm trying to set up a document for publishing to a website, so need to add some HTML tags before and after list items. However, it's not picking the list items up. Can anybody please help? Thanks.

    sub format_list()

            Dim para as Paragraph
            Dim is_list_item as Boolean

            is_list_item = False

            For Each para In ActiveDocument.Paragraphs

                    If para.Range.ListFormat.ListType = WdListType.wdListBullet Then

                            is_list_item = True
                            para.Range.InsertBefore "<li>"
                            para.Range.InsertAfter "</li>"

                    End If

            Next

    End Sub
Was it helpful?

Solution

Try using the following instead of para.Range.InsertAfter "</li>"

para.Range.Select
Selection.EndKey Unit:=wdLine
Selection.TypeText Text:="</li>"
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top