none
Add visual to user so user knows macro is working? RRS feed

  • General discussion

  • Thanks to help in another thread, I have a great macro that removes flags generated on all sorts of mail and meeting items through a rule.  It's like this:

    Sub Clear_Flag_NEW()
        Dim msg As Object
        For Each msg In Application.ActiveExplorer.Selection
    '        If msg.Class = olMail Then     ' original syntax, limits this to _just_ email messages
            If ((msg.Class = olMail) Or (msg.Class = olMeeting) Or (msg.Class = olMeetingRequest) Or (msg.Class = olMeetingAccepted) Or (msg.Class = olMeetingTentative) Or (msg.Class = olMeetingDeclined) Or (msg.Class = olMeetingCancellation) Or (msg.Class = olMeetingCanceled) Or (msg.Class = olMeetingResponsePositive) Or (msg.Class = olMeetingResponseNegative)) Then
                If msg.FlagStatus <> olNoFlag Then
                    With msg
                        .FlagDueBy = #1/1/4501#
                        .FlagRequest = ""
                        .FlagStatus = olNoFlag
                        .FlagIcon = olNoFlagIcon
                        .Save
                    End With
                End If
            End If
        Next
    End Sub

    Because this can take some time to work on a large folder, what would anyone suggest in terms of a visual to the user informing them that the macro is working.

    I thought about putting a message box but then it requires user input to close, afaik.  I'd like something to come up whose purpose is to let user know that a macro is in process and that is intuitive to user that once it winks out, job is done.

    What could do this, please?

    Monday, June 11, 2012 6:00 PM

All replies

  • You can change the mouse cursor to an hourglass, launch a progress form or use an icon in Window's Notification Area (which would most likely require a .NET add-in or the Win32 API).


    Eric Legault
    MVP (Outlook)
    About me...
    Time-saving Outlook Appins
    for as low as $5!

    Tuesday, June 12, 2012 2:22 PM
    Moderator
  • You can change the mouse cursor to an hourglass, launch a progress form or use an icon in Window's Notification Area (which would most likely require a .NET add-in or the Win32 API).

    Eric, hello,

    I managed today to quickly google to see what solution I could come up with.  I didn't find anything relevant.  In Outlook, unlike Excel, changing the cursor to hourglass is nearly impossible it would seem.  In Excel it's as easy as something like this, if all the posts I found are correct:

    Application.Cursor = xlWait
    

         Post this code line before the end of the code to set the cursor back:

    Application.Cursor = xlDefault 

    But in Outlook it seems not to be do-able.  I believe a few posts talked about using a custom form and that you could control the mouse pointer to a certain degree on it but that is not the solution for me.  I need a simple fix to somehow show the user that Outlook is working and then again once Outlook has completed the tasks.  I don't know about forms and coupled with my vba skills being very rudimentary, not sure the answer lies there.  Using that api thing, too, seems beyond me.  I have heard of these APIs before but they seem like overkill.  I need a solution that works easily from host computer to host computer.

    Is there any way to show Outlook is busy that doesn't involve "installing" or really having to change things a lot on the host PC.

    Anyone?  Thank you!!



    • Edited by SGFan Tuesday, June 12, 2012 10:06 PM
    Tuesday, June 12, 2012 10:03 PM
  • There is no avoiding having to use the Win32 API. You can adapt this code:

    Public Declare Function SetCursor Lib "user32" (ByVal hCursor As Long) As Long
    Public Declare Function LoadCursor Lib "user32" Alias "LoadCursorA" (ByVal hInstance As Long, ByVal lpCursorName As Long) As Long
    Public Sub ShowCursor()
    On Error GoTo ShowCursor_Error
        
        Dim lHandle As Long
        lHandle = LoadCursor(0, HourglassCursor)
        If (lHandle > 0) Then SetCursor lHandle
        On Error GoTo 0
        Exit Sub
    ShowCursor_Error:
        MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure ShowCursor" _
            , vbOKOnly + vbExclamation, "Error"
        Resume Next
    End Sub
    Also, see http://www.outlookcode.com for more resources. If this is a multi-user solution, it really should be built as a COM Add-in.  That's how professional solutions are built, and doing things like monitoring progress properly is really a "pro" feature.

    Eric Legault
    MVP (Outlook)
    About me...
    Time-saving Outlook Appins
    for as low as $5!

    Wednesday, June 13, 2012 1:59 PM
    Moderator