none
System.Runtime.InteropServices.Com exception 0x800A03EC in Excel Addin RRS feed

  • Question

  • Not sure if this is VSTO or Sharepoint problem. I am using VSTO for an Excel Addin. I have a problem when syncing with Sharepoint in the Office 365 cloud.
    I use the function: "Globals.ThisAddIn.Application.Workbooks.Open()" to open a copy of a template xlsx file located in a folder sync'd with Sharepoint on line. This works fine as long as the system is connected to the site. If there is no connection to the O365 site, the function throws aSystem.Runtime.InteropServices.Com exception. Hex identifier 0x800A03EC. Anytime I save a workbook within the Addin or from Excel itself, it saves to the folder whether the Sharepoint site is available or not. If I open the template from Excel's File Open dialog, that works OK too and it all syncs when the site is available. It only seems to do this via the above function. I don't see any parameter to make it use local folder if the on line folder is not available. Can  anyone please point me to the error of my ways? I am working around by using the template from the user's documents folder instead.  

    Lou

    Monday, March 27, 2017 1:42 PM

Answers

  • I made a test with your steps, but I failed to reproduce your issue. It works at my side under Windows 10, VS 2015 and Office 2016. What is your environment?

    To check whether it is related with your environment, I suggest you try to make a test in other computers.

    For a workaround, I suggest you try below code:

                string wordFile = @"C:\Users\xxx\OneDrive\Doc1.docx";
                Word.Application wordApp = new Word.Application();
                wordApp.Visible = true;
                wordApp.Documents.Open(wordFile);

    >>If I open the template from Excel's File Open dialog, that works OK too

    For this, I suggest you try to record the steps and share us the recorded macros.


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by Lou Yo Monday, April 3, 2017 2:11 PM
    Monday, April 3, 2017 5:50 AM

All replies

  • Hello Lou,

    >>If I open the template from Excel's File Open dialog, that works OK too and it all syncs when the site is available

    If you are offline and then open the template from Open dialog, would it sync?

    What path do you use in Open method? I suggest you use network file path instead of local path.

    Regards,

    Celeste


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, March 28, 2017 3:03 AM
    Moderator
  • Thank you for the reply

    >>If you are offline and then open the template from Open dialog, would it sync?

    Yes, as I pointed out above. It is only when using that function that it crashes with an exception

    >>What path do you use in Open method? I suggest you use network file path instead of local path.

    The path is the Sharepoint sync assigned local path. If I try to use the network path when not connected, how could that work? Maybe you have an example? 

    The problem is not that it doesn't connect or open, it throws an exception.



    Lou

    Tuesday, March 28, 2017 11:47 AM
  • Hello,

    I am not familiar with SharePoint and we don't have environment to test, but I think the sharepoint sync folder should be similar to OneDrive folder. According to Set up your computer to sync SharePoint Server on-premises files, Whenever you're online, any changes that you or others made will sync automatically. So I think it would not sync till you are online.

    Testing with OneDrive folder, it works no matter what path I used and no matter whether I am online.

           //string path = @"C:\Users\v-chencl\OneDrive\Documents\cases.xlsx";
                string path = "https://d.docs.live.net/89599cf5610d3147/Documents/cases.xlsx";
                Globals.ThisAddIn.Application.Workbooks.Open(path);
     

    Besides, according to the exception, do you have permission to the file or the folder? 


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, March 29, 2017 7:25 AM
    Moderator
  • Thank you again. Yes, I understand about syncing. In fact, this works fine with the Onedrive folder, on line or off line. It is with the Sharepoint folder that it throws the exception, only if I am off line. For some reason, it seems to try to go on line and when it fails it throws an exception instead of going to the local folder like it does with Onedrive. The exception is not for permission or file not found, it is some COM exception. See attached image. 

    Thanks Again

    Edit: Oops, I was wrong. It does the same thing from OneDrive. Exact same exception. 


    Lou


    • Edited by Lou Yo Thursday, March 30, 2017 12:39 AM
    Wednesday, March 29, 2017 12:54 PM
  • Thanks for sharing the test result for OneDrive.

    Since it works when opened by Excel application, I suggest you manually open the file and record a macro to catch the path. Test if the macro works and check if the path is different.

    You may create a new add-in to test the single method. And you may test your current project in other computer to check if the issue exists.


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, March 31, 2017 8:20 AM
    Moderator
  • OK, here is a simple Word addin that will demo what I am seeing in Excel:
    Put a word document in OneDrive, like Doc1.docx
    Now create a new project, C# VSTO Word Addin
    Add a ribbon (designer)
    Add a button to that ribbon.
    In the click function, add:
    string wordFile=@"<path to local onedrive folder>\Doc1.docx";
    try
      {
            Globals.ThisAddIn.Application.Application.Documents.Open(wordFile);
      }
      catch (Exception ex)
      {
           MessageBox.Show(ex.ToString());
       }

    F5 to debug. Under Addins, click button1 (or whatever you named it), the word document loads. Now, disconnect from the Internet and click it again. I get this exception. Perhaps I am doing something wrong, I usually am. I have wasted far too much time on this, I moved my templates to a local folder and may just move everything to the file server and forget about Sharepoint and Onedrive. Not worth the irritation.  

    Lou

    Edit: does same thing with VS2017 on another computer. 
    • Edited by Lou Yo Saturday, April 1, 2017 11:34 AM
    Saturday, April 1, 2017 11:29 AM
  • I made a test with your steps, but I failed to reproduce your issue. It works at my side under Windows 10, VS 2015 and Office 2016. What is your environment?

    To check whether it is related with your environment, I suggest you try to make a test in other computers.

    For a workaround, I suggest you try below code:

                string wordFile = @"C:\Users\xxx\OneDrive\Doc1.docx";
                Word.Application wordApp = new Word.Application();
                wordApp.Visible = true;
                wordApp.Documents.Open(wordFile);

    >>If I open the template from Excel's File Open dialog, that works OK too

    For this, I suggest you try to record the steps and share us the recorded macros.


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by Lou Yo Monday, April 3, 2017 2:11 PM
    Monday, April 3, 2017 5:50 AM
  • Thank you very much. You have the magic touch. I retested both the Word and Excel add--ins and they now work whether the network is connected or not. 

    Famous last words: "I didn't change anything"!!

    Who knows why it started working. Maybe I was the victim of the law of compounding errors and then benefited from the law of offsetting errors.

    The good news is that it made me do more try/catch routines to make sure the user doesn't get an unhandled exception. Thanks again.

    Lou


    Lou

    Monday, April 3, 2017 2:14 PM