Share via

VSTO Problem

Anonymous
2018-06-21T10:48:12+00:00

I am writing a VSTo application and want both the animation pane and selection pane to open on startup.  I have the following code written on the ribbon. load section

        If Not Globals.ThisAddIn.Application.CommandBars.GetPressedMso("AnimationCustom") Then

            Globals.ThisAddIn.Application.CommandBars.ExecuteMso("AnimationCustom")

        End If

        If Not Globals.ThisAddIn.Application.CommandBars.GetPressedMso("SelectionPane") Then

            Globals.ThisAddIn.Application.CommandBars.ExecuteMso("SelectionPane")

        End If

And it keeps generating the following code

-2147467259 Error HRESULT E_FAIL has been returned from a call to a COM component.

I thought it was because there was no powerpoint presentation opened so I added the following but no luck

        Dim ppApplication As PowerPoint.ApplicationClass = Nothing

        Dim ppPresentation As PowerPoint.Presentation = Nothing

        Dim ppSlide As PowerPoint.Slide = Nothing

        ppApplication = New Microsoft.Office.Interop.PowerPoint.ApplicationClass()

        ppPresentation = ppApplication.Presentations.Add

        ppSlide = ppPresentation.Slides.Add(1, PowerPoint.PpSlideLayout.ppLayoutTitleOnly)

        Globals.ThisAddIn.Application.ActiveWindow.ViewType = PpViewType.ppViewNormal

Thoughts?

Microsoft 365 and Office | PowerPoint | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

2 answers

Sort by: Most helpful
  1. Anonymous
    2018-06-22T14:12:24+00:00

    Without seeing the exact structure of your code it is hard to say what is causing the error. But the error is usually thrown when there is no presentation open. Have you tried using GetEnabledMso to ascertain if the buttons are enabled prior to executing then?

    Was this answer helpful?

    0 comments No comments
  2. John Korchok 232.8K Reputation points Volunteer Moderator
    2018-06-21T22:07:08+00:00

    Just a guess, but most of the references online to that error message seem to be connected with 32-bit/64-bit library confusion. Here's one example: Error HRESULT E_FAIL has been returned from a call to a COM component

    Was this answer helpful?

    0 comments No comments