0

While using my PowerPoint Add-in, some users get the following exception: Error HRESULT E_FAIL has been returned from a call to a COM component. It happens when trying to create a new presentation with Application.CommandBars.ExecuteMso("FileNew"), which is supposed to open the backstage tab.

Complications:

  1. The backstage is supported for the user (on PowerPoint 2016)
  2. Official Microsoft documentation states only the return of E_FAIL in case of failure, giving no further clues for C# as well as for VBA
  3. I cannot reproduce the problem on any of the machines available to me

How can I debug and try to prevent this exception?

3
  • 1
    Any chance you can take a look at the Event Viewer of the affected user's PC? There may be some information there, but cannot guarantee so Commented Jun 6, 2018 at 10:18
  • Probably not, but I will try. Thanks for the idea! Commented Jun 6, 2018 at 10:20
  • 1
    It is a documented error code: "E_Fail for controls that are not enabled or not visible". So you must assume that Powerpoint is in a state that does not allow creating a new document, take appropriate counter-measures in your code. Commented Jun 6, 2018 at 10:27

2 Answers 2

1

Thanks to Hans Passant who restated the error code "E_Fail for controls that are not enabled or not visible", I double checked CommandBars object to find out that there are two methods:

  1. Application.CommandBars.GetEnabledMso(CommandName)
  2. Application.CommandBars.GetVisibleMso(CommandName)

So I use the first one to check whether the command is enabled before executing it.

Sign up to request clarification or add additional context in comments.

Comments

0

You need to use the ActivateTabMso of the IRibbonUI interface if you want to activate a particular built-in tab. Then you will be able to use the ExecuteMso method.

You can read more about that in the Ribbon Extensibility in Office 2010: Tab Activation and Auto-Scaling

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.