Results 1 to 6 of 6
  1. #1
    2 Star Lounger
    Join Date
    Dec 2007
    Posts
    179
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Hi all,

    Is it possible to write event handlers to catch mouse clicks on a Word document? (I.e., on the actual pages of the document -- not on a form.)
    I noticed the following events provided by the Application Object, but no mouse single-click event:

    • WindowBeforeDoubleClick
    • WindowBeforeRightClick
    • WindowSelectionChange


    TIA

    - avi

  2. #2
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts
    Avi,

    There is no mouse single-click event per se, but the WindowSelectionChange is pretty nearly the same thing - virtually anywhere you click on the page is going to move the insertion point, which is the same as a selection change, therefore triggering the event.

    What are you specifically trying to do?

    Gary

  3. #3
    2 Star Lounger
    Join Date
    Dec 2007
    Posts
    179
    Thanks
    3
    Thanked 0 Times in 0 Posts
    If I want to implement a mode or two-stage operation, that is completed by clicking on a word or something in the document.

    E.g., to imitate the way Format Painter does its work. You set the mode by clicking on the toolbar button and then complete the operation by clicking (single-clicking is enough) on a paragraph.

  4. #4
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts
    Interesting - never would have thought to try to emulate that. Anyway, WindowSelectionChange might work in this situation.

    Gary

  5. #5
    2 Star Lounger
    Join Date
    Dec 2007
    Posts
    179
    Thanks
    3
    Thanked 0 Times in 0 Posts
    So for WindowSelectionchange, what parameters does it bring with it, if any?

    Wrt the new selection position, I can just pick it up with 'Selection'. (Just tried to format this in Courier. Didn't work.)

  6. #6
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts
    WindowSelectionChange returns the current selection:

    Private Sub App_WindowSelectionChange(ByVal Sel As Selection)

    - and you can then use Selection.Information tests, for example like:

    If Sel.Information(wdWithInTable) = False Then Exit Sub

    - to filter for the Selection condition you want your code to work on.

    Gary

Posting Permissions

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