none
Powerpoint 2010 addin interpo errors RRS feed

  • Question

  • Hello,

    I'm not sure if this is the correct forum to post my question, I did not find a better one, sorry.

    I'm developping a Powerpoint 2010 addin with Visual Studio 2010, when I want to use some properties of the Presentation object, in the Open event for example, I get the next error:

    "The embedded interop type 'ReadOnly' does not contain a definition for 'Microsoft.Office.Interop.PowerPoint.Presentation' since it was not used in the compiled assembly. Consider casting to object or changing the 'Embed Interop Types' property to true."

    Of course that the property "Embed Interop Types" is true, now I'm testing this with a fresh addin without any extra code but didn't work.... so I don't have any idea why powerpoint throw this error...

    (I already has another two addins for Excel 2010 and Word 2010 which has same functions like I want to do for powerpoint, and this addins runs without problems)

    any help would be appreciated, thanks!

    Mauricio.


    mpv
    mpv
    Tuesday, November 29, 2011 7:53 PM

Answers

  • Hi Mauricio

    <<Why VS suggest to set  "Embed Interop Types" property to true?? and why this works fine with Excel and Word but didn't work with Powerpoint?>>

    I have no answer to the latter. As to the former, it's shiny and new and supposed to be a selling point for VS 2010, so .NET Framework 4.0 defaults to this. In theory, it's wonderful as it makes projects PIA (version) independent. But in practice a number of problems are showing up. And not just with PowerPoint.


    Cindy Meister, VSTO/Word MVP
    Thursday, December 1, 2011 6:28 PM
    Moderator

All replies

  • Hi Mauricio

    If this is a VSTO add-in, then you're in the right forum; if it's a "Shared Add-in", then the General Office Development forum would be the more appropriate venue.

    Knowing which kind of add-in also affects the way we'd approach trouble-shooting this. My best guess would be that this is a "Shared Add-in" and that the problem may come from how the references to the PowerPoint PIA has been set.

    Could you also please show us the code that's triggering this error? I'd like to see the declaration and instantiation of all PPT-related objects up to this point, as well...


    Cindy Meister, VSTO/Word MVP
    Wednesday, November 30, 2011 8:30 AM
    Moderator
  • Hi Cindy,

    I creted this addin from VS 2010 - Office 2010 templates (one addin for Word, one for Excel and another for Powerpoint), so I guess that this is a VSTO addin.

    Now in my new fresh testing solution I only have a Powerpoint 2010 addin, in "thisAddin.vb" I have this:

    ==================================================

    Public Class ThisAddIn

        Private Sub ThisAddIn_Startup() Handles Me.Startup

        End Sub

        Private Sub ThisAddIn_Shutdown() Handles Me.Shutdown

        End Sub

        Private Sub Application_AfterPresentationOpen(Pres As Microsoft.Office.Interop.PowerPoint.Presentation) Handles Application.AfterPresentationOpen
            Try
                System.Diagnostics.Debug.WriteLine(Pres.FullName)
                System.Diagnostics.Debug.WriteLine(Pres.Saved)
            Catch ex As Exception
                System.Diagnostics.Debug.WriteLine(ex.Message)
            End Try

        End Sub

        Private Sub Application_PresentationOpen(Pres As Microsoft.Office.Interop.PowerPoint.Presentation) Handles Application.PresentationOpen

            System.Diagnostics.Debug.WriteLine(Pres.FullName)

        End Sub

    End Class 

    ==================================================

    The bold line is which throw the error (the most of properties or methods throws the same error)

    this is my solution explorer view:

     

    and this is powerpoint interop properties window:

    And this is the "Initialize" code in "ThisAddin.Designer.vb":

    ============================================

        <Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
         Global.System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Tools.Office.ProgrammingModel.dll", "10.0.0.0"), _
         Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Never)> _
        Protected Overrides Sub Initialize()
            MyBase.Initialize()
            Me.Application = Me.GetHostItem(Of Microsoft.Office.Interop.PowerPoint.Application)(GetType(Microsoft.Office.Interop.PowerPoint.Application), "Application")
            Globals.ThisAddIn = Me
            Global.System.Windows.Forms.Application.EnableVisualStyles()
            Me.InitializeCachedData()
            Me.InitializeControls()
            Me.InitializeComponents()
            Me.InitializeData()
        End Sub

    =====================================================

    thanks a lot,

    Mauricio.


    mpv
    • Edited by MauricioUY Wednesday, November 30, 2011 4:40 PM
    Wednesday, November 30, 2011 4:35 PM
  • Hi Mauricio

    If I'm seeing correctly in the screenshot of the Properties window, Embed Interop Types is set to True. Try setting that to False and see if it makes any difference in what you're seeing.

     


    Cindy Meister, VSTO/Word MVP
    Wednesday, November 30, 2011 11:08 PM
    Moderator
  • Hi Cindy,

    yes, this change makes differences, I tried this later and got another error when I wanted mark the PPT as saved: "Presentation.Saved : Invalid request.  Presentation cannot be modified.", but now I realized that this is because the PPT was opened from web so this is readonly, despite of the property "ReadOnly" is FALSE......

    Why VS suggest to set  "Embed Interop Types" property to true?? and why this works fine with Excel and Word but didn't work with Powerpoint?

     

    thanks!!

    Mauricio.


    mpv
    Thursday, December 1, 2011 1:58 PM
  • Hi Mauricio

    <<Why VS suggest to set  "Embed Interop Types" property to true?? and why this works fine with Excel and Word but didn't work with Powerpoint?>>

    I have no answer to the latter. As to the former, it's shiny and new and supposed to be a selling point for VS 2010, so .NET Framework 4.0 defaults to this. In theory, it's wonderful as it makes projects PIA (version) independent. But in practice a number of problems are showing up. And not just with PowerPoint.


    Cindy Meister, VSTO/Word MVP
    Thursday, December 1, 2011 6:28 PM
    Moderator