Word Macro: Removing Strike-through Formatting

This Word VBA macro removes all strike-through formatting from an active document.

Macro Example

Sub RemoveStrikeThroughFormatting()
  
  ActiveDocument.StoryRanges(wdMainTextStory).Font.StrikeThrough = False

End Sub

Description

[Application.]ActiveDocument

  ActiveDocument...

The [Application.]ActiveDocument property returns an active Document object.

obj-Word-Application-ActiveDocument

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

obj-Word-ActiveDocument

ActiveDocument.StoryRanges (Document.StoryRanges)

  ActiveDocument.StoryRanges...

The ActiveDocument.StoryRanges (Document.StoryRanges property) returns the StoryRanges collection object.

obj-Word-Document-StoryRanges

StoryRanges(wdMainTextStory) (StoryRanges.Item(wdMainTextStory))

  ActiveDocument.StoryRanges(wdMainTextStory)...

The StoryRanges.Item method returns a single story of a range or selection as a Range object.

obj-Word-StoryRanges-Item

And the StoryRanges.Item(wdMainTextStory) represents the main text story.

The Item method is a default member of the StoryRanges collection object. We can see a little blue marble beside its icon in the Object Browser. So we can omit the .Item .

StoryRanges(wdMainTextStory).Font (Range.Font)

  ActiveDocument.StoryRanges(wdMainTextStory).Font...

The StoryRanges(wdMainTextStory).Font (Range.Font property) returns a Font object that represents the character formatting.

Font.StrikeThrough

  ActiveDocument.StoryRanges(wdMainTextStory).Font.StrikeThrough...

The Font.StrikeThrough property returns True if the font is formatted as strike-through text.

Sub RemoveStrikeThroughFormatting()
  
  ActiveDocument.StoryRanges(wdMainTextStory).Font.StrikeThrough = False

End Sub

Properties

http://www.relief.jp/itnote/archives/word-macro-remove-strikethrough-format-or-delete-strikethrough-text.php

Apply To

  • Word 2013
  • Word 2010
  • Word 2007