How to remove manually typed numbering from a document
Article contributed by Dave Rado
You can use the old Word 2 command:
WordBasic.ToolsBulletsNumbers Replace:=0, Type:=1, Remove:=1
If not familiar with using macros, see What do I do with macros sent to me by other users to help me out?
This command is particularly useful for removing manually typed numbering from Headings in a document you have been emailed, prior to applying List Numbering. If you go into Outline View, set the Heading Level to the number of levels you need to remove the typed numbering from, and run the above line, it will just remove numbering from those Headings and will leave the body text alone. Or you can use the following macro to do the same thing:
Sub RemoveNumbersFromHeadings()
Dim ViewType As Long, ShowHeadingLevel
As Long, MyRange As Range
Application.ScreenUpdating = False
'Set Range variable to current selection so it can
be returned to at the end
Set MyRange = Selection.Range
'Set variable to current View so it can be returned to at
the end
ViewType = ActiveWindow.View.Type
'Switch to Outline View
ActiveWindow.View.Type = wdOutlineView
'Checks the state (using the ID in case the tolbar has been customised) of _
all the ShowHeadings buttons on the Outline toolbar; if none are depressed, _
then it must be set to ShowAll. Stores result in a variable so that _
the same level can be returned to at the end of the macro
For ShowHeadingLevel = 71 To 77
If CommandBars.FindControl(ID:=ShowHeadingLevel).State
Then
ShowHeadingLevel = (ShowHeadingLevel
- 70)
Exit For
End If
Next ShowHeadingLevel
'if none of the heading level buttons depressed sets
variable to 1
If ShowHeadingLevel = 78
Then
ShowHeadingLevel = 1
ActiveWindow.View.ShowHeading 3
ActiveDocument.Select
WordBasic.ToolsBulletsNumbers Replace:=0, Type:=1, Remove:=1
If ShowHeadingLevel = 0 Then
ActiveWindow.View.ShowAllHeadings
Else
ActiveWindow.View.ShowHeading ShowHeadingLevel
End If
ActiveWindow.View.Type = ViewType
MyRange.Select
Set MyRange = Nothing
Application.ScreenUpdating = False
End Sub
Getting Help with WordBasic Commands
Download the old WordBasic help file here
Also see:
Useful WordBasic commands that have
no VBA equivalent
and:
Getting help with calling Word's built-in
dialogs using VBA (and why doing so can be much more useful than you'd think)