• Cursor Behaviour (VBA/Word/SP3)

    Author
    Topic
    #455285
    Option Explicit
    Public Sub CursorDemo()
    Dim Ctr As Byte
    Dim mt As Single

    For Ctr = 1 To 3
    MsgBox "Wait1"
    System.Cursor = wdCursorWait
    mt = Timer
    Do While Timer - mt < 2
    Loop

    MsgBox "Beam"
    System.Cursor = wdCursorIBeam
    mt = Timer
    Do While Timer - mt < 2
    Loop

    MsgBox "Wait2"
    System.Cursor = wdCursorWait
    mt = Timer
    Do While Timer - mt < 2
    Loop

    MsgBox "Normal"
    System.Cursor = wdCursorNormal
    mt = Timer
    Do While Timer - mt < 2
    Loop

    MsgBox "NW Arrow"
    System.Cursor = wdCursorNorthwestArrow
    mt = Timer
    Do While Timer - mt < 2
    Loop

    MsgBox "Normal"
    System.Cursor = wdCursorNormal
    mt = Timer
    Do While Timer - mt < 2
    Loop

    MsgBox "Wait3"
    System.Cursor = wdCursorWait
    mt = Timer
    Do While Timer - mt < 2
    Loop

    Next Ctr
    End Sub

    Can someone tell me why this code fails to consistently change the cursor to an hourglass when called upon to do so. See the highlighted cells in the following table.

    Viewing 0 reply threads
    Author
    Replies
    • #1132588

      Try inserting a line

      DoEvents

      either before the Do … Loop or inside the loop.

      • #1132773

        Hi Hans

        The DoEvents didn’t do it. This System.Cursor has me totally confused. No great feat these days. confused3

        • #1132775

          Strange – it worked for me with the code you posted. (I did see exactly the same behavior that you reported with the original code).

          • #1132933

            Hi Hans
            Perhaps you might take another look at this problem.

            The table in my initial post only told part of the story, in that I now realize that the cursor displayed while displaying the MsgBox is inconsistent.

            When I insert the DoEvents commands the results change, and are consistent when placed in either location which you suggested; though they are not the results which I would expect.

            The attached file contains the results which I expect, and the results obtained with and without the DoEvents commands. It also contains the original code which I posted with the addition of the DoEvents commands and a final MsgBox to remove any ambiguity regarding the final cursor of the test.

            During all tests the cursor was hovering over the document, away from the MsgBox.

            When the cursor was moved over the MsgBox it consistently displayed as a pointer — as expected.

            • #1132941

              I get even less predictable results now, so I can only conclude that System.Cursor is broken, and that you shouldn’t rely on it in your code.

            • #1132954

              Misery loves company. I’m relieved to hear that it’s not just my machine. igiveup

    Viewing 0 reply threads
    Reply To: Cursor Behaviour (VBA/Word/SP3)

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

    Your information: