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. #10
    Quote Originally Posted by gmaxey View Post
    This seems to work:

    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
          para.Range.Select
          '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(2), _
            ContinuePreviousList:=False, ApplyTo:=wdListApplyToWholeList, _
            DefaultListBehavior:=wdWord10ListBehavior
            Exit For
          End If
        Next para
      Next cell
    End Sub
    Thanks greg, that works - I noticed the only change you had to make was to change the parameter in ListTemplates from 1 to 2 - what does that do so that it worked? Was hard to find documentation around this. Is '2' just the 'correct' collection of the bullet points list/styles applicable for me?
    Last edited by Restricted; 09-11-2023 at 09:19 PM.

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
  •