Word Macro: Clearing All Formatting from an Active Document

This Word VBA macro allows us to remove or clear all formatting from the active Word document.

Macro Example

Sub RemoveFormattingActiveDocument()

  ActiveDocument.Select
  Selection.ClearFormatting

End Sub

Description

Selecting Active Document

The 3rd line selects the whole strings on an active document.

Sub...

  ActiveDocument.Select

The Application.ActiveDocument property returns an active Document object.

obj-Word-Application-ActiveDocument

The ActiveDocument property is a member of the Word.Global class, so we can omit the Application property.

obj-Word-ActiveDocument

The Document.Select method (ActiveDocument.Select) selects the whole contents of the active document.

obj-Word-Document-Select

Remove Formatting

The 4th line removes the formattings from the selection by the Selection.ClearFormatting method.

Sub...

  ActiveDocument.Select
  Selection.ClearFormatting

The Selection property returns the Selection object that represents a selected range.

obj-Word-Global-Selection

The Selection property is also a member of the Word.Global class, so we can omit the Application property.

The Selection.ClearFormatting method removes the text and paragraph formatting from a selected range.

obj-Word-Selection-ClearFormatting

After the 4th line is evaluated, this macro ends.

Sub RemoveFormattingActiveDocument()

  ActiveDocument.Select
  Selection.ClearFormatting

End Sub

Properties

http://www.relief.jp/itnote/archives/word-vba-clear-formatting.php

Apply To

  • Word 2013
  • Word 2010
  • Word 2007