Consulting

Results 1 to 15 of 15

Thread: Mail via Outlook non-responsive (Hang: Waiting for OLE...)

  1. #1
    VBAX Contributor
    Joined
    Jul 2017
    Location
    Zurich
    Posts
    126
    Location

    Mail via Outlook non-responsive (Hang: Waiting for OLE...)

    Hi Folks

    I've implemented an error reporting macro that sends an e-mail with the error details upon closing the file.

    The logic behind this is is, whenever an error occurs during runtime, the error details are logged in a dedicated error table within the same workbook.

    Then, upon closing the workbook, a check is done whether the error table is empy or not. If not, a temporary copy of the file is made and send to me via Outllook.

    This procedure worked perfectly for some time, but suddenly it makes Excel non-responsive, and after some time I get a message like:

    "Excel is waiting for another application in order to complete an OLE action"

    This will loop forever!

    The line of code that will start the issue looks like so:

    dim objOutlook as object
    Set objOutlook = CreateObject("Outlook.application")
    I've got Outlook running on my system with no issues otherwise

    Any ideas?

  2. #2
    VBAX Mentor Logit's Avatar
    Joined
    Sep 2016
    Posts
    423
    Location
    .
    Not certain what is occurring there without having access to the workbook and code.

    Here is a basic macro for sending email :

    Sub Send_Mail_From_Excel()
        Dim OutlookApp As Object
        Dim OutlookMail As Object
     
        Set OutlookApp = CreateObject("Outlook.Application")
        Set OutlookMail = OutlookApp.CreateItem(0)
     
        'Send Mass Email Using Excel VBA Macro Code
        With OutlookMail
            .To = ""
            .CC = ""
            .BCC = ""
            .Subject = ""
            .Body = ""
            .Display '‘ or just put .Send to directly send the mail instead of display
            
        End With
     
        Set OutlookMail = Nothing
        Set OutlookApp = Nothing
    End Sub

  3. #3
    VBAX Contributor
    Joined
    Jul 2017
    Location
    Zurich
    Posts
    126
    Location
    it seems that it depends on the Outlook open/closed status, but not sure if it's only that. However, as far as I can tell:

    If already open, the CreateObject("Outlook.Application") will lead to a crash. So this seems to work for now at least:

         Set objOutlook = GetObject(, "Outlook.Application")
         If Err.Number = 429 Then
              Err.Clear
              Set objOutlook = CreateObject("Outlook.Application")
              If Not Err.Number = 0 Then
                   Exit Sub
              End If
         End if 
         On Error GoTo Fehler
         Set objMail = objOutlook.CreateItem(0)
    The app hang is still a mistery though
    I'm not a programmer (well newby) but I don't understand why the windows crash log doesn't provide any valuable information

  4. #4
    VBAX Contributor
    Joined
    Jul 2017
    Location
    Zurich
    Posts
    126
    Location
    I've found another issue with the "Excel is waiting for another application in order to complete an OLE action" alert:

    Indeed it happens that my Outlook is not responsive and I need to kill the task via task manager. In that case the OLE automation alert will pop up like every 10 seconds and will loop endlessly.

    Is there a way to stop my macro from running after the first alert message has been shown? Or in case of application.displayalerts = false when it would have been shown?

  5. #5
    VBAX Mentor Logit's Avatar
    Joined
    Sep 2016
    Posts
    423
    Location
    .
    In the past I've experienced the same issue you are describing. My solution was to have Outlook open and running in the background. However you have indicated
    doing so causes the macro to crash on your machine.

    Question : Have you setup Outlook to connect with your email server ? For example, I have Outlook setup to connect to my Yahoo Email account.

  6. #6
    VBAX Contributor
    Joined
    Jul 2017
    Location
    Zurich
    Posts
    126
    Location
    Today I've found that Outlook goes into several states. I'm running Win10 and Office 365 on my private PC. At work with Win8 and Office 2013 this is not happening.

    Those beeing: Outlook running/not running, handled by another application, and closing

    So, on my private PC, let's assume Outlook is closed, then things seem to run as expected. However, if it's already running it might send the email one time and then go into the state of being handled by another application (showing this last symbol: Outlook handled.jpg)
    In that case the mail is sent, but things get weird afterwards.

    Then, it can happen, for reasons unknown yet to me, that Outlook goes into closing (Outllook closing.jpg), but it will never ever close. At that point there is nothing I can do other than kill Excel and Outlook altogether.

    I've got no idea, but maybe I need to get rid of the "Outlook is handled by another application" after sending an email.

  7. #7
    VBAX Mentor Logit's Avatar
    Joined
    Sep 2016
    Posts
    423
    Location
    .
    I wish I could answer your question. Maybe someone else on the Forum can assist ?

  8. #8
    VBAX Contributor
    Joined
    Jul 2017
    Location
    Zurich
    Posts
    126
    Location
    I havent't found any solutions to this issue yet, and ive never experienced this behaviour before. But I supect that it is related to the the 1809 windows update

  9. #9
    VBAX Mentor Logit's Avatar
    Joined
    Sep 2016
    Posts
    423
    Location
    .
    The only way I know to determine if that is the cause would be to return your system to a previous backup date ... or reload Windows without accepting updates until
    you have tested the workbook.

  10. #10
    VBAX Contributor
    Joined
    Jul 2017
    Location
    Zurich
    Posts
    126
    Location
    I've read today that MS recognized this hang issue and has recommended to uninstall the last office update. great stuff

  11. #11
    VBAX Mentor Logit's Avatar
    Joined
    Sep 2016
    Posts
    423
    Location
    .
    Gotta love MS !

  12. #12
    VBAX Contributor
    Joined
    Jul 2017
    Location
    Zurich
    Posts
    126
    Location
    Is there a way to detect this state, ie. "Excel is waiting for an OLE application..." in order to handle the issue without killing outlook manually?

  13. #13
    VBAX Mentor Logit's Avatar
    Joined
    Sep 2016
    Posts
    423
    Location
    .
    If I correctly understand your request ... you can create a simple error handler, then direct VBA to do what you need.

    Here is an example from this resource : https://stackoverflow.com/questions/...data-not-avail


    Sub Sample()
        On Error GoTo Whoa
    
    
        '<REST OF YOUR CODE>
    
    LetsContinue:
        Exit Sub
    
    
    
    Whoa:
        '~~> This gives the exact desription and the error number of the error
        MsgBox "Description     : " & Err.Description & vbNewLine & _
               "Error Number    : " & Err.Number
    
    
        '~~> This part resumes the code without breaking it :)
        Resume LetsContinue
    End Sub
    The above doesn't correct anything. It simply displays the error then attempts to continue the code afterwards / exits the sub without doing anything more.

    I presume you could replace the last part of the above error code to quit/shut down Excel via code commands if that is your wish.

    Did you mention that MS states the cause is an update to Win. Have you specifically inquired of MS if there is a 'workaround' to circumvent the
    error via VBA code ?


    If you are not familiar, this website appears to have lots more folks who either work for MS or have their various MS Certifications. Perhaps posting your question
    there would give you another avenue for a solution, as it has been several weeks since you've had activity on this thread.

    https://stackoverflow.com/

  14. #14
    VBAX Contributor
    Joined
    Jul 2017
    Location
    Zurich
    Posts
    126
    Location
    Hi Logit

    In fact you are not correct. I'm aware of proper Error Handing, however this one is escaping the error handling, because office thinks that there is no error around.
    As mentioned at some point, I guess this is related to a bug in outlook. And that should be resolved by Microsoft later or sooner or the other way lol.

  15. #15
    VBAX Mentor Logit's Avatar
    Joined
    Sep 2016
    Posts
    423
    Location
    .
    Ok ... my apologies ... I totally missed it.



    (I'm going back to my safe space 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
  •