Word Macro: Switching the Superscription of the Selected Text

This Word VBA macro switches on and off the superscription of the selected text.

Macro Example

Sub ToggleSuperscription()

  Selection.Font.Superscript = wdToggle

End Sub

Description

[Application.]Selection

  Selection...

The Application.Selection property returns the Selection object that represents the current selection in a window or pane of Word.

obj-Word-Application-Selection

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

obj-Word-Global-Selection

Selection.Font

  Selection.Font...

The Selection.Font property returns or sets a Font object that represents the character formatting.

obj-Word-Selection-Font

Font.Superscript

  Selection.Font.Superscript...

The Font.Superscript property returns True if the font is formatted as superscript.

obj-Word-Font-Superscript

Toggles the Value

  Selection.Font.Superscript = wdToggle

The wdToggle is very interesting constant. This toggles a property’s value.
If the value is True, it switches to False.
If the value is False, it switches to True.

Sub ToggleSuperscription()

  Selection.Font.Superscript = wdToggle

End Sub

Properties

http://www.relief.jp/itnote/archives/word-vba-superscript-selection.php

Apply To

  • Word 2013
  • Word 2010
  • Word 2007