George Spears
Posts: 79
Joined: 2010-05-06
|
Hello,
I have a plug in that works for both Word and Excel. I have a button on the ribbon toolbar that allows the user to close/open a pane. I have this working for Excel, but I can't get it working for Word.
In Excel, my code is
if Pos('EXCEL.EXE', Application.ExeName) > 0 then
begin
adxExcelTaskPanesManager1.Items[0].Enabled := not adxExcelTaskPanesManager1.Items[0].Enabled;
if (adxExcelTaskPanesManager1.Items[0].Enabled) then
begin
if adxExcelTaskPanesManager1.Items[0].TaskPaneInstance = nil then
begin
taskPane := adxExcelTaskPanesManager1.Items[0].CreateTaskPaneInstance;
if (taskPane <> nil) then
begin
taskPane.Show;
end;
end;
end;
end;
This works fine.
I have converted my code to TRY to work with Word. I am fairly confident my issue has to do with the fact that Word creates a task pane for every opened Doc, but I don't know how to deal with that.
Here is my attempt...
if Pos('WINWORD.EXE', Application.ExeName) > 0 then
begin
adxWordTaskPanesManager1.Items[0].Enabled := not adxWordTaskPanesManager1.Items[0].Enabled;
if (adxWordTaskPanesManager1.Items[0].Enabled) then
begin
if adxWordTaskPanesManager1.Items[0].CurrentTaskPaneInstance = nil then
begin
// NEXT LINE IS MY PROBLEM
WordPane := adxWordTaskPanesManager1.Items[0].Create(adxWordTaskPanesManager1.Items);
if (WordPane <> nil) then
begin
WordPane.Show;
end;
end;
end;
end;
How do I need to change my 'WordPane := ' line?
Thanks
GS |
|
Andrei Smolin
Add-in Express team
Posts: 18829
Joined: 2006-05-11
|
Hello George,
if HostType = ohaWord then
begin
adxWordTaskPanesManager1.Items[0].Enabled := not adxWordTaskPanesManager1.Items[0].Enabled;
if (adxWordTaskPanesManager1.Items[0].Enabled) then
begin
adxWordTaskPanesManager1.Items[0].ShowTaskPane
end;
end;
Andrei Smolin
Add-in Express Team Leader |
|