+ Reply to Thread
Results 1 to 4 of 4

Thread: How do I avoid Hourglass using API Function?

  1. #1
    Forum Contributor sauerj's Avatar
    Join Date
    11-11-2009
    Location
    Lafayette, IN
    MS-Off Ver
    Excel 2003
    Posts
    116

    Smile How do I avoid Hourglass using API Function?

    Hello, In MS WORD (version 2003), I am trying to use a Windows API MessageBoxA function in place of the VBA built-in MsgBox() function. Why? I want the message box to be modeless so that user can select text inconjunction w/ the operating macro, and, to me, building a UserForm for these multiple user interactive tasks is much too cumbersome.
    This API approach works OK, except for one issue. When I run the macro and move my mouse outside of the MB window, the cursor is displayed as an HOURGLASS. The HOURGLASS will confuse the user. What can I do to get the HOURGLASS to turn back to a normal arrow cursor.
    NOTE: If I right-click when outside of the API window and then left-click, the HOURGLASS goes away. ... Also, if the macro is started while in the VB editor window, then the HOURGLASS never occurs. So, seems like there would be a way to avoid this hourglass.
    Any help is greatly appreciated. ... Thank you, sauerj

    PS: See attachment which contains the macro containing these MessageBox API functions.

    Cross-Post LINK: http://www.msofficeforums.com/word/5...-function.html

    SOLVED ... Found My Own Solution: See post below (from sauerj) for details!
    Attached Files Attached Files
    Last edited by sauerj; 11-10-2010 at 08:44 AM. Reason: Added Cross-Post Link

  2. #2
    Valued Forum Contributor MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Seattle, WA
    MS-Off Ver
    Excel 2010
    Posts
    5,318
    One test is worth a thousand opinions.
    Click the * below to say thanks.

  3. #3
    Forum Contributor sauerj's Avatar
    Join Date
    11-11-2009
    Location
    Lafayette, IN
    MS-Off Ver
    Excel 2003
    Posts
    116

    Re: How do I avoid Hourglass using API Function?

    If I put System.Cursor = wdCursorNormal ahead of the API MsgBox function (see code below), it does remove the hourglass, BUT only after hovering the mouse over the MsgBox window. Any other ideas to avoid the hourglass 100%????

    Is there something about how the API HANDLE is setup that impacts this????

     System.Cursor = wdCursorNormal
     UserPromptCommand = APIMsgBox(prompt:="Select insertion range where you want to insert cross-reference." & _
       Chr(13) & Chr(13) & "Hit OK when complete and ready for macro to continue" & Chr(13) & _
       "Hit CANCEL to QUIT.", buttons:=vbOKCancel + vbInformation + vbDefaultButton2 + vbSystemModal, _
       title:="Cross Reference: ... Prompt user to select insertion range")  'Instruct user

  4. #4
    Forum Contributor sauerj's Avatar
    Join Date
    11-11-2009
    Location
    Lafayette, IN
    MS-Off Ver
    Excel 2003
    Posts
    116

    Re: How do I avoid Hourglass using API Function?

    Found My Own Solution:
    Sending ALT key removed the last instance of the HOURGLASS.
    In the end, gave up on API Message Box and switched to using a User Form for this. Didn't like that API Message Box kept putting box back in the CENTER of the window (which requires user to move it every time). For multiple user interactions, this was unacceptable. The Form technique fixed all of this. However, don't like that VBA BEEP command makes NO NOISE; but that's small potatoes. ... sauerj

     System.Cursor = wdCursorNormal
     SendKeys "%"
     UserPromptCommand = APIMsgBox(prompt:="Select insertion range where you want to insert cross-reference." & _
       Chr(13) & Chr(13) & "Hit OK when complete and ready for macro to continue" & Chr(13) & _
       "Hit CANCEL to QUIT.", buttons:=vbOKCancel + vbInformation + vbDefaultButton2 + vbSystemModal, _
       title:="Cross Reference: ... Prompt user to select insertion range")  'Instruct user
    Last edited by sauerj; 11-10-2010 at 08:45 AM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.2.0