chriscode
chriscode

Reputation: 151

How to detect if user is interacting with "File Tab" in PowerPoint?

I am looking for a way to determine when a user clicks the "File Tab" (and potentially any of the sub tabs marke the following dialog is shown in PowerPoint (see screenshot).enter image description here

I tried checking the ActiveWindow.ViewType but it does not change when the user opens the dialog. I also tried checking the Panes for their respective "Active" Property but it also does not change when the user is on this screen.

I also tried this code, but to no avail.

    <DllImport("user32.dll")>
    Private Shared Function GetForegroundWindow() As IntPtr
    End Function

    If GetForegroundWindow() <> Globals.ThisAddIn.Application.HWND Then
         Exit Function
    End If

I noticed that Keyboard input is not possible while this dialog is shown but I don't know how to check this within a VSTO solution. User32 IsWindowEnabled() returns True when the dialog is shown.

Any ideas? Thanks

Upvotes: 0

Views: 75

Answers (1)

Eugene Astafiev
Eugene Astafiev

Reputation: 49395

The Backstage UI provides two callbacks you are interested in:

  • onShow
VBA: Sub OnShow(contextObject As Object)
C#: void OnShow(object contextObject)
Visual Basic: Sub OnShow(contextObject As Object)
C++: HRESULT OnShow([in] Object *pContextObject)
  • onHide
VBA: Sub OnHide(contextObject As Object)
C#: void OnHide(object contextObject)
Visual Basic: Sub OnHide(contextObject As Object)
C++: HRESULT OnHide([in] Object *pContextObject)

Read more about that in the Introduction to the Office 2010 Backstage View for Developers article.

Upvotes: 1

Related Questions