Access a Word Task Pane's Components

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

Access a Word Task Pane's Components
 
GKoehn


Guest


In the event TAddInModule.adxWordAppEvents1DocumentBeforeClose, I need to access a label on the TadxWordTaskPane1 which is a TadxWordTaskPane. How can I do that?
Posted 10 Jun, 2015 15:51:12 Top
Andrei Smolin


Add-in Express team


Posts: 18828
Joined: 2006-05-11
Hello Gregory,

As you probably know we don't recommend accessing a pane in this event.

What do you need to do after you access the label?


Andrei Smolin
Add-in Express Team Leader
Posted 11 Jun, 2015 05:17:21 Top
GKoehn


Guest


If my client has http://www.worldox.com/ installed, Worldox defaults to prohibit the closing of Word the normal way. Users can only close documents by using the file-close menu. When you do this in Word 2010, you have a Word shell with no document open. The Task Pane is still showing. The labels and components on the task pane still are showing data related to the last opened document. I am trying to get the components to clear under this situation. Would you have some code to clear the task pane when no documents are open?
Posted 11 Jun, 2015 10:22:03 Top
Andrei Smolin


Add-in Express team


Posts: 18828
Joined: 2006-05-11
Gregory,

I would intercept the OnDocumentChange event that the Word Events component provides. In the event procedure you clear the pane if the WordApp.ActiveDocument property returns nil; as far as I remember it produces an exception if there's no document open.


Andrei Smolin
Add-in Express Team Leader
Posted 12 Jun, 2015 04:17:12 Top
GKoehn


Guest


This seems to work...


procedure TAddInModule.adxWordAppEvents1DocumentChange(Sender: TObject);
var
  wdoc: WordDocument;
begin
  try
    wdoc := WordApp.ActiveDocument;
  except
  end;
  if wdoc = nil then
    (adxWordTaskPanesManager1.Items[0].CurrentTaskPaneInstance as TadxWordTaskPane1).Label1.Caption := 'Docs all closed!';
end;


Does that look right?
Posted 12 Jun, 2015 11:25:37 Top
Andrei Smolin


Add-in Express team


Posts: 18828
Joined: 2006-05-11
Hello Gregory,

It seems to be okay. I would also check if adxWordTaskPanesManager1.Items[0].CurrentTaskPaneInstance returns nil.


Andrei Smolin
Add-in Express Team Leader
Posted 15 Jun, 2015 02:47:50 Top