Results 1 to 11 of 11

Thread: Macro to reformat text not working - help

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #8
    Thanks Greg - that worked.

    How can we also modify the code (or a new, separate code/function) to change any numbered bullet points (e.g. 1., 2., 3., 4.) into lettered bullet points (e.g. A., B., C., D.). Example was demonstrated in 'Sample Original' and 'Sample to appear like' (page 2) respectively in attachment above.

    I have tried something like this, but it does not work well - it makes everything (including non-bulleted text) bulleted, and in some cases, 'restarts' the numbered list (so 'A.' appears 4 times, instead of A, B, C, D in sequence).

    Sub ConvertListsInTableToNumbered()
        Dim tbl As Table
        Dim cell As Cell
        Dim para As Paragraph
        
        ' Define the table we want to process
        Set tbl = ActiveDocument.Tables(1) ' Change the table index as needed
        
        ' Loop through each cell in the table
        For Each cell In tbl.Range.Cells
            ' Loop through each paragraph in the cell
            For Each para In cell.Range.Paragraphs
                ' Check if the paragraph has a numbered or bulleted list format
                If para.Range.ListFormat.ListType <> wdListNoNumbering Then
                    ' Convert the list to a numbered list
                    para.Range.ListFormat.ApplyListTemplate ListTemplate:= _
                        ListGalleries(wdNumberGallery).ListTemplates(1), _
                        ContinuePreviousList:=False, ApplyTo:=wdListApplyToWholeList, _
                        DefaultListBehavior:=wdWord10ListBehavior
                End If
            Next para
        Next cell
    End Sub
    Last edited by Restricted; 09-10-2023 at 11:22 PM. Reason: what I tried

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •