none
Insert Excel SpreadSheet RRS feed

  • Question

  • Hi,

    I am trying to find a way to insert an excel spreadsheet on PowerPoint slide using VSTO (Office 2010) with VS2010. Similar to when I do the 'Insert -> Table -> Excel Spreadsheet'.

    I did try this code:

     Dim oShape As PowerPoint.Shape = Nothing

     oShape = Application.ActiveSlide.Shapes.AddOLEObject(30, 70, 660, 440, "Excel.Sheet", "", Microsoft.Office.Core.MsoTriState.msoFalse, "", 0, "", Microsoft.Office.Core.MsoTriState.msoFalse)

    it did generate a excel object but when I double click on it, I got an error:

    "The server application, source file, or item can't be found, or returned an unknown error. You may need to reinstall the server application"

    Can I ask what is the proper way to insert a blank excel spreadsheet using VSTO?

    Thanks,

    Chris

    Wednesday, March 2, 2016 7:25 PM

All replies

  • Hi Chris,

    >> I am trying to find a way to insert an excel spreadsheet on PowerPoint slide using VSTO (Office 2010) with VS2010

    Which VSTO project you are developing? Based on your code, it seems you are not developing PowerPoint add in. I made a test with the code below which is Powerpoint add in under PowerPoint 2010.

      Dim oShape As PowerPoint.Shape = Nothing
            oShape = Globals.ThisAddIn.Application.ActivePresentation.Slides(1).Shapes.AddOLEObject(30, 70, 660, 440, " Excel.Sheet", "", Microsoft.Office.Core.MsoTriState.msoFalse, "", 0, "", Microsoft.Office.Core.MsoTriState.msoFalse)

    I could reproduce your issue, and after I run this code, I manually insert a Excel Sheet, open Excel sheet which is created manully, then both Excel sheet table could be opened. I assume it is related with Powerpoint 2010.

    I made a test with PowerPoint 2013, it works correctly. I suggest you try Office 2013.

    Best Regards,

    Edward


    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.



    Thursday, March 3, 2016 2:26 AM
  • Hi Edward,

    I am developing Powerpoint addin for Office 2010, we are not ready for Office 2013 yet.

    I did try the manual insert excel spreadsheet too and it does work as expected. But I really need to automate to insert excel spreadsheet via code, so you think there is no solution for this issue?

    The strange thing is, it sometimes throw different exception error with below codes,

    Dim oShape As PowerPoint.Shape = Nothing

     oShape = Application.ActiveSlide.Shapes.AddOLEObject(30, 70, 660, 440, "Excel.Sheet", "", Microsoft.Office.Core.MsoTriState.msoFalse, "", 0, "", Microsoft.Office.Core.MsoTriState.msoFalse)
     Dim oWB As Excel.Workbook = Nothing
     oWB = TryCast(oExcelShape.OLEFormat.Object, Excel.Workbook)

    Sometimes I got this error, do you why?

    System.Runtime.InteropServices.COMException was caught
     ErrorCode=-2147220995 System.Runtime.InteropServices.COMException was caught
     HResult=-2147220995
     Message=Object is not connected to server (Exception from HRESULT: 0x800401FD (CO_E_OBJNOTCONNECTED))


    Thanks,

    Chris

    Sunday, March 6, 2016 2:47 AM
  • Hi Chris,

    What is the definition of “Application” in your code? With a clean PopwerPoint VSTO project, I could not test with your code. Could you share us a complete code?

    As my test in my above reply, I think we could not insert excel spreadsheet via code under Office 2010, and I suggest you make a test with Office 2013.

    Best Regards,

    Edward


    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 7, 2016 9:01 AM