Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #4  
Old 02-16-2017, 01:42 PM
macropod's Avatar
macropod macropod is offline Macro to number sentences Windows 7 64bit Macro to number sentences Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,521
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Try:
Code:
Sub Demo()
Application.ScreenUpdating = False
Dim i As Long, Rng As Range
With ActiveDocument.Range
  For i = 1 To .Sentences.Count
    With .Sentences(i)
      .InsertBefore " "
      Set Rng = .Characters.First
      Rng.Collapse wdCollapseStart
      .Fields.Add Range:=Rng, Type:=wdFieldSequence, _
        Text:="No.", PreserveFormatting:=False
    End With
  Next
End With
Set Rng = Nothing
Application.ScreenUpdating = True
End Sub
With this code, the numbering is applied via SEQ fields. Had I hard-coded the numbers, you would have had to re-number every sentence after the first one that gets mis-numbered; this way simply deleting the offending numbers then updating the fields (e.g. Ctrl-A, F9) - which you can leave till all the offending numbers have been deleted - is all you need do.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Get paragraph number from macro brice Word VBA 4 06-30-2015 03:29 AM
How to find number of coma and then add that number of rows in word using macro? PRA007 Word VBA 7 05-27-2015 10:45 PM
Macro to number sentences Global macro across a number of different word files daffy Word VBA 6 07-08-2014 05:42 PM
Macro to number sentences Need a Macro that Combines Every 5 sentences into a paragraph jgarland Word 22 01-11-2012 11:19 AM
Macro to number sentences Page number Macro kimsi Word 3 11-15-2011 11:54 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 04:35 PM.


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