Results 1 to 9 of 9
  1. #1
    4 Star Lounger
    Join Date
    Apr 2001
    Posts
    482
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Pausing, clicking, and recording the click spot (VBA Word 2000)

    OK, this is going to sound convoluted. We have some insanely complicated standards for doing Callouts (from the AutoShape list) in our documentation. I have managed to do macros for some aspects of it, but am far from satisified.

    This is what I'd like:

    1. Run the macro and popup a msgbox that tells the user to click on the graphic for the location they want the callout. (This part is no problem.)

    2. Pause the macro while the user clicks the item to which the callout is pointing.

    3. Have the macro record the coordinates of the click, and then draw a callout from that location to a spot above or below the graphic.

    I have an existing macro that can format the callout from there.

    Am I nuts for asking this or can this really be done? VBA has often surprised me with its functionality. I'm hoping for that here.

    Thanks!!
    Troy

  2. #2
    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: Pausing, clicking, and recording the click spot (VBA Word 2000)

    I have not done anything like this, but I have a couple of thoughts:

    1. <LI>Run the macro and popup a msgbox that tells the user to click on the graphic for the location they want the callout. (This part is no problem.)

      <UL><LI>If you use a non-modal UserForm, the user will not have to click OK before clicking the graphic, but this could create other problems.
    <LI>Pause the macro while the user clicks the item to which the callout is pointing.

    <UL><LI>Using a non-modal UserForm might allow you to display information about the user's click so that the user can click again if he or she "missed."[/list]<LI>Have the macro record the coordinates of the click, and then draw a callout from that location to a spot above or below the graphic.

    <UL><LI>There are Windows API methods for detecting click locations inside a window, but I'm not sure how you would convert that to the position on the shape itself. I checked to see if either an InlineShape or Shape in the document is understood by Windows as a distinct thing, and found no evidence that it is (see attached graphic). A lot of math might be involved here, working from where the click was in the document (from Windows) and the Left and Top settings of the Shape... because I don't see any way to make a Shape respond to a click event.[/list][/list]I have a completely different thought: what if the user clicks the shape, you then show it in a preview window on a UserForm and ask the user to click where they want the callout. I think you can get a precise measurement of the click on the UserForm, but I've never had to do it, so hopefully someone else will chime in.
    Attached Images Attached Images

  3. #3
    Gold Lounger
    Join Date
    Dec 2000
    Location
    New Hampshire, USA
    Posts
    3,386
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Pausing, clicking, and recording the click spot (VBA Word 2000)

    To get right-click menus in Word, you have to add/modify the built-in short cut menus supplied by Word.

    It is word that controls the contet and determines which menus pop up where, all you can do is add to those menus.

    Note what I said was true for Word 97 and Word 2000.
    I've not yet looked into Word 2002 for this and maybe Smart Tags could be used instead in Word 2002, but I have not looked yet, waiting for someone to pay me to do so.

  4. #4
    4 Star Lounger
    Join Date
    Apr 2001
    Posts
    482
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Pausing, clicking, and recording the click spot (VBA Word 2000)

    Howard, thanks for your response, but I wonder after reading it if you meant to reply to a different thread. If you did mean to respond to my thread, please explain what you response has to do with recording the location of click and drawing a callout.

    Thanks!!
    Troy

  5. #5
    4 Star Lounger
    Join Date
    Apr 2001
    Posts
    482
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Pausing, clicking, and recording the click spot (VBA Word 2000)

    Where would I find the Windows API methods for detecting click locations? I've never worked with Windows API methods before, but would love to give it try.

    Thanks!!
    Troy

  6. #6
    Gold Lounger
    Join Date
    Dec 2000
    Location
    New Hampshire, USA
    Posts
    3,386
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Pausing, clicking, and recording the click spot (VBA Word 2000)

    THe bible is Dan Appleman's book on the Win 32 API.
    Also take a look at Steve Roman's Win32 API Programming.

  7. #7
    4 Star Lounger
    Join Date
    Apr 2001
    Posts
    482
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Pausing, clicking, and recording the click spot (VBA Word 2000)

    Sounds interesting, but also like a lot of work to learn a skill I may not use much.

    Consider this idea:

    1. I temporarily create a table the same size as the picture, with each cell 1 pt square, floating on top of the graphic.

    2. The user would click in the grid that most closely matches the place on the graphic they want to call out.

    3. Then I create the callout and move it to that spot using the adjustment object, etc.

    I don't think I'll need any coding help to do this, but wondered if you thought the idea was sound. I know it may not be as precise and perfect, but it does seem like it could work and would not require me to dive into the Windows API.

    Let me know your thoughts!!
    Troy

  8. #8
    Platinum Lounger
    Join Date
    Dec 2000
    Location
    Queanbeyan, New South Wales, Australia
    Posts
    3,730
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Pausing, clicking, and recording the click spot (VBA Word 2000)

    I don't think you will need an API to determine coordinates. The Mousedown event for a form (and for many controls) gives the X and Y coordinates.
    Subway Belconnen- home of the Signboard to make you smile. Get (almost) daily updates- follow SubwayBelconnen on Twitter.

  9. #9
    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: Pausing, clicking, and recording the click spot (VBA Word 2000)

    That would be a good reason to show the graphic on a UserForm, rather than working with a click in the document workspace, if that's easily done.

    On further thought, and after playing with the callout feature a bit, it seems to affix itself not to an arbitrary spot on a graphic, but to a paragraph. Thus, maybe it makes more sense to measure where the user clicks in relation to the document itself, and ignore the fact that the user happens to be clicking on a shape.

    On further examination, I realize I hardly know anything about shapes or even how to effectively change their Z-order (he says, with great frustration), so, maybe I'll just go away now.

Posting Permissions

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