none
Microsoft.Office.Core.FileDialog.Execute() method throw ComException when Excel editing language differ from system locale RRS feed

  • Question

  • The following code works fine when I used English locale for the current user. But dialog.Execute() throw the exception when I changed to non English locale for the current user. This issue only happen on Excel, if I change the editing language to be same as system locale, then this issue is gone. Any ideas?

    The code:

    Microsoft.Office.Core.FileDialog dialog =this.Application.get_FileDialog(Microsoft.Office.Core.MsoFileDialogType.msoFileDialogSaveAs);

    int result = dialog.Show();

    if (result != 0)

    {

    dialog.Execute(); 

    The exception:

    System.Runtime.InteropServices.COMException (0x80004005): Error HRESULT E_FAIL has been returned from a call to a COM component.

    I follow the http://support.microsoft.com/kb/320369 article to set Culture of current thread to en-US, but it still throw exception, is there any other solution?

    The purpose of my addin is getting the saved path and file name. Is there WorkbookAfterSave event? If yes, then I don't need to pop up Save as dialog in WorkbookBeforeSave event and set Cancel to true.

    Best regards,

    Erison

    Monday, March 26, 2012 7:09 AM

All replies

  • Hi Erison,

    Thanks for posting in the MSDN Forum.

    Would you please tell me you Office version and VSTO runtime version for further research

    Have a good day,

    Tom


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us

    Wednesday, March 28, 2012 4:42 AM
    Moderator