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? |
|
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;
|
|