View Single Post
 
Old 08-08-2021, 05:29 PM
Guessed's Avatar
Guessed Guessed is offline Windows 10 Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,176
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

If you are processing almost every paragraph I don't see the usefulness of using the Find command. I note that your sample has two input lists but only one of them was an autolist. This code is set up to recognise a hard-coded list by the presence of ".tab" so it works with your sample but may not work with other lists if they don't use that pattern
Code:
Sub SetupQuiz()
  Dim iParaNum As Long, aRng As Range, aPara As Paragraph
  Set aRng = ActiveDocument.Range  'or Selection.Range
  For iParaNum = aRng.Paragraphs.Count To 1 Step -1
    Set aPara = aRng.Paragraphs(iParaNum)
    aPara.Range.Select
    Select Case aPara.Style
      Case "ans", "Q"
        'do nothing
      Case Else
        If aPara.Range.ListFormat.ListType = wdListNoNumbering Then
          aPara.Style = "t"
          If aPara.Range.Text Like "*." & vbTab & "*" Then aPara.Style = "tt"
        Else
          aPara.Range.ListFormat.ConvertNumbersToText
          aPara.Style = "tt"
        End If
    End Select
  Next iParaNum
End Sub
Note that the code has to work backwards to avoid autonumbered list items renumbering if the preceding paragraph is converted before you process the next paragraph.
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote