FAQ

Frequently asked questions for self help.

Please take a quick look at common questions (and answers) in the default list. If you can't find what you're looking for, start off by selecting your Ability Office version and then narrow it down by entering search text and/or category.

Knowledge base article 94

Write macro to delete previous/next word

Some word processors (including Ability Write v4) support "Delete Previous Word" when Ctrl-Backspace is pressed. Similarly "Delete Next Word" for Ctrl-Delete. This macro example shows how Ability can made to do the same and includes how to assign a keystroke to a macro.

1. Start Write

2. Select Tools/Macros/Macro Editor

3. Copy and Paste all the text below into the Macro editor screen.

Sub DelPrevWord
  With ActiveDocument
    i = .Selection.End -1 
    ch = .Text(i)

    While ch = 32
      i = i - 1
      If i < 0 Then
        ch = "0"
      Else
        ch = .Text(i)
      End If
    Wend
  End With 

  With ActiveDocument.Selection 
    .Start = i
    .Collapse abForw
    .Cut
  End With

End Sub

Sub DelNextWord
  With ActiveDocument
    i = .Selection.End
    ch = .Text(i)

    While ch = 32
      i = i + 1
      If i > .Text.Count Then
        ch = "0"
      Else
        ch = .Text(i)
      End If
    Wend
  End With

  With ActiveDocument.Selection
   .End = i
   .Collapse abBack
   .Cut
  End With
End Sub

4. Click the Save button

5. Use the Window menu to return to your document (any document)

6. Select Tools/Customize and the Macro Shortcuts tab

7. Click on the Macro DelPrevWord

8. Click in the "Select New Shortcut" edit box and press Ctrl-Backspace

9. Click "Assign" button

10. Repeat 7 to 9 with DelNextWord macro and Ctrl-Delete

11. Save and test