none
Office 2007 Service Pack 2 Issue RRS feed

  • Question

  • Hi All,

    I have been VSTO development for a while, and everything worked fine until I had to do some coding for PowerPoint chart. For accessing the charts in powerpoint, I had to install Office service pack 2. And I added the Excel, and PowerPoint references from the Com tab to ensure my application is pointing to right DLLs. 

     

    Now when I try to convert Chart.ChartData.Workbook after activating the workbook, I am getting the following error : 

     

    Unable to cast COM object of type 'System.__ComObject' to interface type 'Microsoft.Office.Interop.Excel.Workbook'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{000208DA-0000-0000-C000-000000000046}' failed due to the following error:  could not be found. (Exception from HRESULT: 0x80030002 (STG_E_FILENOTFOUND)).

     

    I assume, the id of the returned workbook is different from what I have added in reference. I don't know whats wrong. Can someone please help?

     

    Thanks,

    Vikas

     


    http://excelnoob.blogspot.com
    Sunday, April 17, 2011 6:46 AM

Answers

  • Hi Vikas

    Did you add these references in the COM tab before or after updating to SP2? If before, try removing them and adding them again. SP2 did definitely change the basic *.exe files and the *.dll files for the object model in order to add the functionality for the charting object model.

    Also, you should access the Chart object model through PowerPoint and not through Excel. The charting engine is "shared" between the Office applications (meaning it's not part of the Excel object model, but a separate Office object model) and has been inherited by each application so that no additional reference is required in order to use it. So it will be something like (pseudocode) MyChart = new PptApp.Shapres.AddChart();


    Cindy Meister, VSTO/Word MVP
    Monday, April 18, 2011 6:42 AM
    Moderator

All replies

  • Hi Vikas

    Did you add these references in the COM tab before or after updating to SP2? If before, try removing them and adding them again. SP2 did definitely change the basic *.exe files and the *.dll files for the object model in order to add the functionality for the charting object model.

    Also, you should access the Chart object model through PowerPoint and not through Excel. The charting engine is "shared" between the Office applications (meaning it's not part of the Excel object model, but a separate Office object model) and has been inherited by each application so that no additional reference is required in order to use it. So it will be something like (pseudocode) MyChart = new PptApp.Shapres.AddChart();


    Cindy Meister, VSTO/Word MVP
    Monday, April 18, 2011 6:42 AM
    Moderator
  • Hi Cindy,

     

    Sorry for replying too late. The problem was resolved after I started my Visual Studio in Administrator mode. I think, I was not able to explain my problem clearly. I was able to access chart object through the exact sequence and I followed the correct procedure to create a chart object.

     

    In the PowerPoint chart Class, there is a property called ChartData.Workbook which represents the workbook which contains the Chart Object.

     

    In an ideal situation, I would do something like following :

     

     

    xl.Workbook workbook = ppChart.ChartData.Workbook as xl.Workbook.
    

     

      But the "ppChart.ChartData.Workbook" property was returning a Workbook object with a different component ID and which I was unable to typecast in xl.Workbook type. And, I was getting the error mentioned in my first post.

     

    What I am assuming is, (just my Guess, correct me if I am Wrong) that when I was started running my Visual Studio in admin mode, it also looked at the exact Workbook object, which was returned by the ChartData.Workbook property. Not sure about the reason though. I hope you may be able to put more lights on it.

     

    Thanks for the Help!

    Vikas B


    My Blog My Profile
    Tuesday, August 30, 2011 12:11 PM