Deleting Text

Range .Deleteā€”If used without arguments, this method deletes the entire Range. However, you can fine-tune your deletions by using the following syntax:

The Range object containing the text you want to delete.

(optional) A constant that specifies whether you're deleting characters (use wdCharacter) or entire words (use wdWord). If you omit this argument, VBA assumes you're deleting characters.

(optional) The number of units to delete. Use a positive number to delete forward; use a negative number to delete backward. (The default is 1.)

Range Unit

Count

For example, the following statement deletes five characters, starting at the current cursor position:

Selection.Delete Unit:=wdCharacter, Count:=5

0 0

Post a comment