none
How to debug - Microsoft Excel is waiting for another application to complete an OLE action caused by my VSTO addin RRS feed

  • Question

  • I have developed a VSTO Excel addin for Excel 2007 with Visual Studio 2010.  The addin is used on a number of computers which use Windows 7 x64 with Office 2007.  Windows and Office are in German and English.

    Every so often like maybe once a day Excel shows "Microsoft Excel is waiting for another application to complete an OLE action" clicking ok does not help and the message returns.  You must end the excel process to get out of the loop.

    When it does happen it generally happens when a second xlxs file is being opened and that second file is being clicked on either from a network drive or from Outlook. People have told me that it will happen two times in a row and then Excel will work fine for the rest of the day.

    Why do I think it is my app.  Well many other people dont have my Addin and they dont have the problem and it seems that when my addin is disabled then it does not happen.

    I tried to zero in on the problem by reducing my code down to only this;

    Private Sub ThisAddIn_Startup() Handles Me.Startup
    
            Dim smartTagFile As Microsoft.Office.Tools.Excel.SmartTag = Globals.Factory.CreateSmartTag("MYApp#MYApp_File_Smart_Tag", "MYApp File")
    
            smartTagFile.Expressions.Add(New Regex("(?<![A-Z\d])(?:(?:19|20)?\d\d[A-Z]\d{5}((\s\s?(?!WO|WE|EP)[A-Z]{2}(?![A-Z]{2})|(?:WO|WE|EP)[A-Z]{2}|(?:WO|WE|EP|[A-Z]{2}))(0[1-9]|1[0-5])?)?|(?:19|20)\d{7})(?!\d)"))
    
    
            IpasAkzAction = Globals.Factory.CreateAction("File Lookup.")
    
            smartTagFile.Actions = New Microsoft.Office.Tools.Excel.Action() {IpasAkzAction}
    
            Me.VstoSmartTags.Add(smartTagFile)
    
        End Sub
    
     Private Sub ThisAddIn_Shutdown() Handles Me.Shutdown
    
    end sub

    This is all that is left in my addin.

    Now when it is fully coded it calls my own .NET dll which is registered in the GAC.  Whilst the code above does not mention this I have tested two versions of my code 1 with my .dll referenced even though there is no code and 1 where it is not referenced and I think that the error happens when it is referenced but does not happen when it is not referenced, but I have only tested this on one computer with one person so far.

    I have checked with the Fusion log and it reports that the Addin itself is being loaded properly.

    So I would love to ask what is causing the error but after reading may of the posts on this error message I have not read a single answer that directly solved the problem.

    So I will try another way.  What programs can I use to debug excel for such problems like this?  They must be able to work on a non-development computer.

    Friday, March 21, 2014 4:42 PM

Answers

All replies

  • Hello,

    It looks like you didn't specify the term to recognize. Am I right?

    Please take a look at the How to: Add Smart Tags to Excel Workbooks article in MSDN. It describes all the required steps for developing an Excel smart tag and provides a sample code in C# and VB.NET. I'd recommend using the sample code for reproducing the issue instead. Does it work?

    You can use a debug build with Debug.WriteLine statements for logging. So, at runtime you can see what's happening in the code. 

    Friday, March 21, 2014 5:28 PM
  • Hello,

    It looks like you didn't specify the term to recognize. Am I right?

    Yes you are right.  As far as I am aware and from the linked example I can use either a term or expression or both?  I am simple using an expression.

    You can use a debug build with Debug.WriteLine statements for logging. So, at runtime you can see what's happening in the code.

    as far as I understand when a second file is started by clicking on the .xlxs file absolutely no code in my addin is called.  Thus I dont see how this helps.

    • Edited by donky73 Friday, March 21, 2014 6:55 PM
    Friday, March 21, 2014 6:53 PM
  • Yes, you can use a term and expression, or both.

    Did you try to run a sample code shown in the article? Does it work?

     
    Friday, March 21, 2014 7:20 PM
  • yes i have run the code and I dont get any errors.
    Friday, March 21, 2014 8:56 PM
  • Well, it confirms my assumptions that the cause is located in your code/regular expression.
    Friday, March 21, 2014 9:03 PM
  • yes I agree.  So lets get back to my original idea of how to attach a debugger to excel or to my addin on a non-development pc.  By the way I have set VSTO to log by setting the environment variable, but I have not seen a log file as of yet.  But I dont think Excel has shown the error message as of yet.
    Saturday, March 22, 2014 5:35 AM
  • Hi,

    According to the message, I found a KB:

    Excel is waiting for another application to complete an OLE action.

    It provides three methods, have you tried these methods?

    Also, you can try using Application.DisplayAlerts property to avoid the message.

    To debug Excel Add-ins, please look at the article below:

    Debugging in Application-Level Projects

    Hope this helps.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, March 24, 2014 6:26 AM
    Moderator
  • Thank you for helping.


    According to the message, I found a KB:

    Excel is waiting for another application to complete an OLE action.

    I have looked at this. No.1 and 2 do not apply.  I assume No.3 "The Excel worksheet tries to access data from another application that is still active." could be a Possibility.  Follow the method No.3 I confirm that adding my Addin to excel "can" cause the error to happen.  Thus I am happy to say it is my addin.

    Also, you can try using Application.DisplayAlerts property to avoid the message.

    Firstly I don't think this is a solution to an error.  This might work when Excel is calling a modal window or doing a long query of a data base but not in this case.  1. I would have to disable alerts in StartUP meaning that for the whole Excel session the user would have no alerts. 2. The error message from Excel keeps coming back after clicking ok, meaning that what ever the dam OLE ACTION IS (and all I want to find out is what it is) the OLE action that Excel is waiting for does not resolve itself. (tells me that it is a COM Marshalling problem I think)

    To debug Excel Add-ins, please look at the article below:

    Debugging in Application-Level Projects

    Firstly I cannot get Excel to error on my developer computer.  Secondly Excel does not error reliably. It happens once or twice a day during the course of a work day but might also go the whole day and not error at all.

    I have yesterday implemented the Troubleshooting start up errors by setting VSTO_LOGALERTS to 1 and hope that VSTO does show something and I hope even more it does show something that you can work with.

    Correct me if I am wrong but this message may or may not be coming from Excel. I have read it might be an OS message? Are there windows logs which show something on this?

    Am I correct that "Microsoft.Office.Tools.Excel.SmartTag" is not an OLE object?

    Does Microsoft.Office.Tools.Excel.SmartTag or any of its objects require Marshalling due to COM interop?

    Other than this being a COM interop issue I want to know it is not the case that the Regex expression is too complicated for Excel and thus it does not want to wait to check the worksheet. 

    Would one way to check this be to use "Implements ISmartTagExtension" and thus use my own custom "Sub Recognize" method and then log this method.  Now I will see if excel has a problem with the recognition right?

    For example see the Walk Through Here.

    Thanks in advance.



    • Edited by donky73 Tuesday, March 25, 2014 8:54 AM
    Tuesday, March 25, 2014 8:39 AM
  • Ok one small update Excel has shown the error message again on a PC with VSTO_LOGALERTS set to 1.  And guess what nothing was logged.  As the addin is in the Programs Folder I am assuming the log would be written to %temp%.

    So VSTO_LOGALERTS is as useful as mammilla on a bull in this case.

    Thursday, March 27, 2014 6:59 AM
  • In desperation I have "thrown" a few GC.Collect and GC.WaitForPendingFinalizers in the addin (especially at shutdown) to try and see if this helps at all.

    It has not helped.

    Most people say that the error message is shown after they have clicked on an excel file which was attached to an Outlook email.  Does this ring any alarm bells for anyone?

    Monday, March 31, 2014 9:13 AM
  • I have finally got this to error on my PC. It does not happen with 100% reliability but I can get it to error.  I get it to error by opening and closing at least 2 excel files by clicking on the files in Windows Explorer. When I click on the 2nd or 3rd file to open it errors. Never the first file. It also seems it has to be files that have been open before.  So I open 2 files, close them and then open again. Upon opening the 2nd file for the 2nd time Excel is unresponsive and eventually shows the error message.

    1. All other excel addins have been made inactive.
    2. If I just have a blank addin with just the two methods of startup and shutdown and no code in them - NO ERROR.
    3. If I have the above startup code I get the error.
    4. If I make Excel Options > Add-Inns > Manage > SmartTags > Unclick my VSTO Recognizer NO ERROR.

    So I can now conclude.

    1. It is a problem with my code - my addin etc and not another addin.
    2. My addin itself is not the problem it is the smarttag recognizer

    I hope I still have people reading this.  I also hope this might mean someone can give me some tips on what to do next.

    Wednesday, April 2, 2014 7:54 AM
  • Hi,

    Since the thread is old, I would recommend you to repost a new thread.

    Then you need to tell us what is the problem and how to reproduce it (Maybe you should provide a simple sample and tell us the steps).

    So that other community members would join in.

    Thanks for your understanding.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, April 2, 2014 8:56 AM
    Moderator
  • Thanks.  I will do just that.
    Wednesday, April 2, 2014 11:50 AM