Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 12-06-2021, 09:06 PM
Bikram Bikram is offline Changing list numbering Windows 10 Changing list numbering Office 2007
Advanced Beginner
Changing list numbering
 
Join Date: Jul 2021
Location: Nepal
Posts: 90
Bikram is on a distinguished road
Post Changing list numbering

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
Reply With Quote
  #2  
Old 12-06-2021, 10:10 PM
Guessed's Avatar
Guessed Guessed is offline Changing list numbering Windows 10 Changing list numbering Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,966
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

Can you explain why you are converting autonumbers to manual numbers? It would be fully adaptable if you just ensure the styles have the right numbering applied and local formatting is cleared.
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #3  
Old 12-07-2021, 12:47 AM
Bikram Bikram is offline Changing list numbering Windows 10 Changing list numbering Office 2007
Advanced Beginner
Changing list numbering
 
Join Date: Jul 2021
Location: Nepal
Posts: 90
Bikram is on a distinguished road
Default

I have to change autonumbering to manual numbering because I have to change the
123 list format to abc formats and abc format to i,ii,iii and they are not multilevel lists and it was formatted into multilevel by indenting text if I had to change the list format and then update the styles then they would have caused the text to move and cost me more time so I thought changing them to manual numbering and then changing the list would save me some time so I chose that option.

And I wanted to write a code that would be more dynamic than this. So, i posted it here so that I could learn more. Would you please show me how can this code be written more efficient way??

Thanks in advance.
Reply With Quote
  #4  
Old 12-07-2021, 02:04 PM
Guessed's Avatar
Guessed Guessed is offline Changing list numbering Windows 10 Changing list numbering Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,966
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

'More dynamic' code would be using automatic numbering. Moving to manual numbering is the opposite of dynamic and your reason for this is not valid.

Can you post a sample document and tell us if the code needs to restrict itself to these two styles ONLY when they are used inside tables.
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #5  
Old 12-07-2021, 09:33 PM
Bikram Bikram is offline Changing list numbering Windows 10 Changing list numbering Office 2007
Advanced Beginner
Changing list numbering
 
Join Date: Jul 2021
Location: Nepal
Posts: 90
Bikram is on a distinguished road
Default

Actually, At first, those styles were in auto numbering but I accidentally ran the code Activedocument.range.listformat.convertnumberstote xt to .docx files while I was looping through files and they were converted to manual numbering and saved. So Selection.range.listformat.convertnumberstotext was for .doc documents which were not changed into manual numbering.

Below is the sample document. Which process would be easier and time-efficient for me? To change the numbering by using the code I posted above or to change them into autonumbering again and then delete numberings like 1., 2. etc and then change them into desired list numbering. So, for the sake of convenience, I used the above method. If there is another way to solve this problem. Please, guide me.
Attached Files
File Type: docx Sample.docx (14.2 KB, 5 views)
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Alignment is changing after numbering hit 100 kingston123 Word 2 08-11-2021 11:04 AM
Changing list numbering List Numbering Set Numbering Value shows missing numbers as hidden text 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
Changing list numbering List Style Numbering picks up out of order number from LATER list 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

Other Forums: Access Forums

All times are GMT -7. The time now is 08:17 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft