Results 1 to 3 of 3
  1. #1
    New Lounger
    Join Date
    Mar 2003
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Word macro (Word 2000)

    We've a had a problem with users inadvertantly selecting blocks of type in Word and then deleting the type, without realizing it right away. Is it possible to write a macro, which would warn the users when they have selected more than X number of characters?

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Word macro (Word 2000)

    The internal command for deleting text is EditClear. If you write a macro with that name, it will replace the internal command. It doesn't prevent the user from selecting a block and overtyping it with a single character. For that, uncheck the Overwrite Selection option in Tools/Options..., Edit tab.

    Here is a macro:

    Sub EditClear()
    If Selection.Characters.Count > 10 Then
    If MsgBox("You are about to delete a large amount of text. Are you sure?", _
    vbQuestion + vbYesNo) = vbNo Then Exit Sub
    End If
    Selection.Delete
    End Sub

  3. #3
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Word macro (Word 2000)

    > Is it possible to write a macro, which would warn the users when they have selected more than X number of characters?

    Yes, but I think that would get annoying, don't you?

    I tried to write an event procedure that would detect whether the number of characters in the document had just decreased by more than 10, ask the user if it was intentional and then Undo if it wasn't, but I could not find a reliable way to Undo the type-over. Part of the problem might be that each Undo triggered the procedure to run again before it was actually finished. Anyway, lots of crashes and document corruption resulted, so I'm not going to post the code. Maybe some other idea will occur to me...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •