![]() |
#1
|
|||
|
|||
![]()
Greeting to all the members, Recently I tried to change lists. For Example, I changed 1 to a, 2 to be, and so on from style name list1 and similarly changed a to i, b to ii, and so on from list2. The macro I wrote works as expected but the macro that I created is lengthy and I just want to know if that can be shortened so that the macro works efficiently and code would be dynamic.
Sub ChangingNumberslists() Dim i As Integer Dim rng As Range Dim ipara As Long Dim opara As Paragraph Dim st As Style Set rng = ActiveDocument.Range ipara = rng.Paragraphs.Count For i = ipara To 1 Step -1 Set opara = rng.Paragraphs(i) Set st = opara.Range.Style If opara.Range.Information(wdWithInTable) = False Then opara.Range.Select If st = "List1" Then Selection.Range.ListFormat.ConvertNumbersToText Selection.MoveLeft Unit:=wdWord, Count:=1 Selection.MoveRight Unit:=wdWord, Count:=2, Extend:=wdExtend With Selection.Range.Font .Name = "Lato heavy" .Size = 7.5 End With Select Case Selection.Text Case "1." Selection.TypeText Text:="a." Case "2." Selection.TypeText Text:="b." Case "3." Selection.TypeText Text:="c." Case "4." Selection.TypeText Text:="d." Case "5." Selection.TypeText Text:="e." Case "6." Selection.TypeText Text:="f." Case "7." Selection.TypeText Text:="g." Case "8." Selection.TypeText Text:="h." Case "9." Selection.TypeText Text:="i." Case "10." Selection.TypeText Text:="j." End Select End If If st = "list2" Then Selection.Range.ListFormat.ConvertNumbersToText Selection.MoveLeft Unit:=wdWord, Count:=1 Selection.MoveRight Unit:=wdWord, Count:=2, Extend:=wdExtend With Selection.Range.Font .Name = "Lato heavy" .Size = 7.5 End With Select Case Selection.Text Case "a." Selection.TypeText Text:="i." Case "b." Selection.TypeText Text:="ii." Case "c." Selection.TypeText Text:="iii." Case "d." Selection.TypeText Text:="iv." Case "e." Selection.TypeText Text:="v." Case "f." Selection.TypeText Text:="vi." Case "g." Selection.TypeText Text:="vii." Case "h." Selection.TypeText Text:="viii." Case "i." Selection.TypeText Text:="ix." Case "j." Selection.TypeText Text:="x." End Select End If End If Next End Sub |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Alignment is changing after numbering hit 100 | kingston123 | Word | 2 | 08-11-2021 11:04 AM |
![]() |
lostenfeld | Word | 9 | 01-03-2017 04:27 PM |
Changing a list indentation changes its numbering | osama | Word | 7 | 03-31-2015 02:46 AM |
![]() |
spthomas | Word | 12 | 12-16-2013 05:23 PM |
Changing Figure Numbering Fields 0-1, 0-2, 0-3 | chrishart7 | Word | 0 | 09-03-2010 12:59 PM |