Is it possible to start Office application with hidden task pane and control visibilty after?

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

Is it possible to start Office application with hidden task pane and control visibilty after?
Add-in Express for Microsoft Office and .net, Standard 
David Potashinsky


Guest


In our flow we decide about visibility of task pane only after Office document is opened.
We need a way to initialize task pane as hidden to prevent flickering during Office start.

D.P.
Posted 22 Sep, 2016 02:50:00 Top
Andrei Smolin


Add-in Express team


Posts: 18806
Joined: 2006-05-11
David,

To prevent a pane from showing, you handle the ADXBeforeTaskPaneShow event of the pane class and set the Visible property to true (visible) or false (invisible). To show or hide the pane call the Show() or Hide() methods of the pane class.


Andrei Smolin
Add-in Express Team Leader
Posted 22 Sep, 2016 03:14:04 Top
David Potashinsky


Guest


generally it's OK. but please help me with a fallowing flow:
on _WorkbookActivateEvent I try to store ExcelPane when Excels stars, but adxExcelTaskPanesCollectionLock.TaskPaneInstance is null if I suppress it's creation by creating hidden pane.
so I have no access to pane during Excel startup.
I need a way to access (or create) pane when excel stars. Please help.

D.P.
Posted 22 Sep, 2016 08:46:34 Top
Andrei Smolin


Add-in Express team


Posts: 18806
Joined: 2006-05-11
David Potashinsky writes:
so I have no access to pane during Excel startup.


The pane is created/shown/hidden/resized/modved following the "events" that occur in the window system of Excel, not in the Excel object model. This is why the pane may be missing in that event; see also section https://www.add-in-express.com/docs/net-outlook-regions-panes-ui.php#form-instances-programmatically.

Instead of thinking in the from-excel-event-to-pane way, you should think in the opposite direction: when the Excel task panes manager shows an instance of the pane and the ADXExcelTasPane.ADXBeforeTaskPaneShow event is raised, what value doI set to the ADXExcelTasPane.Visible property?

Does this make sense?


Andrei Smolin
Add-in Express Team Leader
Posted 22 Sep, 2016 08:59:19 Top
David Potashinsky


Guest


Maybe it does. However then I have related question:
in few flows I need to run code in context of Windows Main thread. when I have an access to object like Task Pane I can do it in style:
Invoke(new MethodInvoker(() =>
{
label_info.Text = txt;
}));
how can I run "Invoke" in another, not Windows classes of Addin ?

10x, D.P.
Posted 26 Sep, 2016 01:22:52 Top
Andrei Smolin


Add-in Express team


Posts: 18806
Joined: 2006-05-11
Hello David,

Add-in Express panes provide the ADXPostMessage method. Invoking it raises the ADXPostMessageReceived event which always occurs on the main thread. Similarly, the add-in module itself provides the SendMessage method which raises the OnSendMessage event on the main thread, too. See also section https://www.add-in-express.com/docs/net-office-tips.php#wait-a-little.


Andrei Smolin
Add-in Express Team Leader
Posted 26 Sep, 2016 07:51:14 Top
David Potashinsky


Guest


Thank you, all good, but what if is need enable/disable ribbon button from non window thread?
in this case I don't really have object which is able to get post message. How should I run code in context of window thread?

d.p.
Posted 05 Oct, 2016 04:05:39 Top
Andrei Smolin


Add-in Express team


Posts: 18806
Joined: 2006-05-11
Hello David,

See the ADXAddinModule.SendMessage() method and ADXAddinModule.OnSendMessage event. They implement the mechanism described in section https://www.add-in-express.com/docs/net-office-tips.php#wait-a-little.


Andrei Smolin
Add-in Express Team Leader
Posted 05 Oct, 2016 04:21:41 Top