Detect Word Protected View

Add-in Express™ Support Service
That's what is more important than anything else

Detect Word Protected View
BeforeTaskPaneShow how to detect Protected View 
GKoehn


Guest


I have a TadxWordTaskPane for MS Word.
I need to hide my Task Pane if Word is in Protected View.
I would love to detect this mode in the OnADXBeforeTaskPaneShow event.
Any ideas on how I can do this?
Posted 02 Oct, 2013 18:59:09 Top
Dmitry Kostochko


Add-in Express team


Posts: 2875
Joined: 2004-04-05
Hi Gregory,

Please see the code sample below. Note, the ActiveProtectedViewWindow property was added to the Word 2010 Object Model.


uses adxWordProtectedView_IMPL; // access to TAddInModule

procedure TadxWordTaskPane1.adxWordTaskPaneADXBeforeTaskPaneShow(ASender: TObject; Args: TadxBeforeTaskPaneShowEventArgs);
var
  ProtectedWindow: IDispatch;
begin
  // check Word version (14 = Office 2010)
  if (Self.AddinModule as TAddInModule).HostMajorVersion >= 14 then begin
    // get the ActiveProtectedViewWindow property
    ProtectedWindow := OleVariant(Self.WordAppObj).ActiveProtectedViewWindow;
    if Assigned(ProtectedWindow) then
      try
        // hide the form
        Self.Visible := false;
      finally
        ProtectedWindow := nil;
      end;
  end;
end;
Posted 03 Oct, 2013 06:16:02 Top
GKoehn


Guest


Works Great!
Thanks!
Posted 03 Oct, 2013 10:07:03 Top