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

    Home » Forums » AskWoody support » Productivity software by function » Visual Basic for Applications » Pausing, clicking, and recording the click spot (VBA Word 2000)

    Author
    Topic
    #372965

    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

    Viewing 0 reply threads
    Author
    Replies
    • #597967

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

      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.)
        • 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.
    • Pause the macro while the user clicks the item to which the callout is pointing.
      • 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]
      • 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.
        • 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.
    • #598031

      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.

      • #598052

        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

    • #598070

      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

      • #598097

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

        • #598204

          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

    • #598374

      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.

      • #598402

        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.

Viewing 0 reply threads
Reply To: Pausing, clicking, and recording the click spot (VBA Word 2000)

You can use BBCodes to format your content.
Your account can't use all available BBCodes, they will be stripped before saving.

Your information: