atw: Word tips: useful macro "one-liners"

  • From: Craig Hadden <CraigH@xxxxxxxxxxxxxxxxxxx>
  • To: "'austechwriter@xxxxxxxxxxxxx'" <austechwriter@xxxxxxxxxxxxx>
  • Date: Tue, 15 Jun 2004 14:47:27 +1000

Below are three very simple Word macros that I find extremely useful on a
daily basis. 

The macros let you:
* press Alt+Delete to delete the current row or rows of a table
* press Alt+Insert to paste plain text, without formatting
* press Ctrl+% to highlight the Zoom box for zooming in or out
* easily transport custom Word keyboard shortcuts between PCs

(Some or all of these features might be available out of the box in current
versions of Word, but I'm working in Word 97 at the moment.

Also, because e-mail virus checkers often prevent Word macro code getting
through, I've inserted lots of tilde characters in an effort to disguise the
code. You'll need to find-and-replace tildes (~) with nothing to make the
code usable. After that, you should be able to press Alt+F11 in Word to open
a code window, and then paste the cleaned-up macros.)

I hope you find these useful.

Cheers,
Craig

'>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Su~b delete_current_row()
'Deletes the current row or rows of a table i.e. the row containing
'    the insertion point or the row or rows in which text is selected,
'    if any.
'This macro is equivalent to choosing "Table:Delete Cells:Delete entire
row:OK"
'    (or "Table:Select Row" followed by "Table:Delete Row").
'Key assigned: Alt+Del (See ASSIGN_KEYS macro, below)
'Macro written 09/04/99 by Craig Hadden (in Word 6!)
    On Err~or Resume Next 'Exits the macro if we're not in a table.
    Word~Basic.Table~DeleteRow
End Su~b

Su~b paste_plain_text()
'Pastes text without any formatting, so that the text adopts the
'    formatting current at the position of the insertion point.
'    For example, this is useful when pasting text copied from
'    another document.
'This macro is equivalent to choosing
'    "Edit:Paste Special:Unformatted Text:OK"
'Key assigned: Alt+Ins (See ASSIGN_KEYS macro, below)
'Macro written 05/11/99 by Craig Hadden
    Selection.~PasteSpecial DataType:~=wdPasteText
End Su~b

Su~b assign_keys()
'You can copy macros from 1 document or template to
'    another (using Word's Organizer dialog box), but
'    you can't copy key assignments. However, you can
'    copy this macro to overcome the inability to
'    copy key assignments!
'(You can find out the names of elusive wd~Key constants
'    by recording a macro that assigns the keys in
'    question to an arbitrary command, such as File | Open.)
'This macro does not overwrite any of Word's default key assignments.
'Macro written 06/01/00 by Craig Hadden
    Con~st ALT = wd~KeyAlt, _
          CTRL = wd~KeyControl, _
          SHIFT = wd~KeyShift
          
    CustomizationContext = NormalTemplate 'Rather than ActiveDocument or
ActiveDocument.AttachedTemplate
    
'>> Macros...
    KeyBindings.~Add _
        Command:~="delete_current_row", _
        KeyCode:~=BuildKeyCode(wd~KeyDelete, ALT), _
        KeyCategory:~=wd~KeyCategoryMacro
    KeyBindings.~Add _
        Command:~="paste_plain_text", _
        KeyCode:~=BuildKeyCode(wd~KeyInsert, ALT), _
        KeyCategory:~=wd~KeyCategoryMacro

'>> Commands...
    'Makes Ctrl+% (Ctrl+Sh+5) equivalent to clicking the Zoom box...
    KeyBindings.~Add _
        Command:~="ViewZoom", _
        KeyCode:~=BuildKeyCode(wd~Key5, CTRL, SHIFT), _
        KeyCategory:~=wd~KeyCategoryCommand
End Su~b
'<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
**************************************************
To post a message to austechwriter, send the message to 
austechwriter@xxxxxxxxxxxxxx

To subscribe to austechwriter, send a message to 
austechwriter-request@xxxxxxxxxxxxx with "subscribe" in the Subject field.

To unsubscribe, send a message to austechwriter-request@xxxxxxxxxxxxx with 
"unsubscribe" in the Subject field.

To search the austechwriter archives, go to 
www.freelists.org/archives/austechwriter

To contact the list administrator, send a message to 
austechwriter-admins@xxxxxxxxxxxxx
**************************************************

Other related posts:

  • » atw: Word tips: useful macro "one-liners"