Range.Delete Method (Word)
Office 2013
Deletes the specified number of characters or words.
expression .Delete(Unit, Count)
expression Required. A variable that represents a Range object.
Parameters
Name | Required/Optional | Data Type | Description |
|---|---|---|---|
Unit | Optional | Variant | The unit by which the collapsed range is to be deleted. Can be one of the WdUnits constants. |
Count | Optional | Variant | The number of units to be deleted. To delete units after the range, collapse the range and use a positive number. To delete units before the range, collapse the range and use a negative number. |
Return Value
Long
This example selects and deletes the contents of the active document.
Sub DeleteSelection()
Dim intResponse As Integer
intResponse = MsgBox("Are you sure you want to " & _
"delete the contents of the document?", vbYesNo)
If intResponse = vbYes Then
ActiveDocument.Content.Select
Selection.Delete
End If
End Sub