checking if called from embedded application

1

11x22

Hi,

I have a problem which I can't find an easy workaround. I have three
addins for Word, Excel and PowerPoint. They actually share the same code
for drawing themselves on toolbar and such things. Everything works nice,
unless user puts some embedded Excel sheets in Word or embedded Word
documents in Excel or PowerPoint and so on.

Different strange things start to happen when he clicks in this embedded
objects. onStartupComplete() happens but it is not always able to draw
toolbar icons properly and sometimes he gets one icon instead of two, or
doesn't get icon pictures and so on.

I decided that the best way to workaround this strange behavior is to
disable my addins when clicked into embedded objects. But there is a
problem, I can't find an universal way to check whether
onStartupComplete() is called from "normal" Word/Excel/PowerPoint or is
caused by clicking "into" embedded object.

The only thing which worked in excel was comparing Application.Hwnd with
GetActiveWindow(). This works nice, but there is no Application.Hwnd in
Word or PowerPoint.

I figured out that calling GetWindowText() on GetActiveWindow() while in
onStartupComplete() in Word always returns an empty Caption when clicking
into embedded object. But that is not true for PowerPoint, GetWindowText()
on GetActiveWindow() in onStartupComplete() just always returns an empty
string.

And this just look like hack to me. And anyway I'm not able to think of
anything to determine whether the powerpoint's onStartupComplete() is
caused by actually launching powerpoint document or by clicking into
PowerPoint embedded object.

Is there any way to find out whether we are called by clicking into
embedded Word/Excel/PowerPoint in onStartupComplete()?
 
C

Cindy M.

Hi 11x22,

For Powerpoint, try checking the ActiveWindow.Caption property of the
Powerpoint application object. A quick test (using VBA) gives me something
like "Slide in Document1".
I have a problem which I can't find an easy workaround. I have three
addins for Word, Excel and PowerPoint. They actually share the same code
for drawing themselves on toolbar and such things. Everything works nice,
unless user puts some embedded Excel sheets in Word or embedded Word
documents in Excel or PowerPoint and so on.

Different strange things start to happen when he clicks in this embedded
objects. onStartupComplete() happens but it is not always able to draw
toolbar icons properly and sometimes he gets one icon instead of two, or
doesn't get icon pictures and so on.

I decided that the best way to workaround this strange behavior is to
disable my addins when clicked into embedded objects. But there is a
problem, I can't find an universal way to check whether
onStartupComplete() is called from "normal" Word/Excel/PowerPoint or is
caused by clicking "into" embedded object.

The only thing which worked in excel was comparing Application.Hwnd with
GetActiveWindow(). This works nice, but there is no Application.Hwnd in
Word or PowerPoint.

I figured out that calling GetWindowText() on GetActiveWindow() while in
onStartupComplete() in Word always returns an empty Caption when clicking
into embedded object. But that is not true for PowerPoint, GetWindowText()
on GetActiveWindow() in onStartupComplete() just always returns an empty
string.

And this just look like hack to me. And anyway I'm not able to think of
anything to determine whether the powerpoint's onStartupComplete() is
caused by actually launching powerpoint document or by clicking into
PowerPoint embedded object.

Is there any way to find out whether we are called by clicking into
embedded Word/Excel/PowerPoint in onStartupComplete()?

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 
1

11x22

For Powerpoint, try checking the ActiveWindow.Caption property of the
Powerpoint application object. A quick test (using VBA) gives me something
like "Slide in Document1".
Thank you for your reply, I will surely try, but that's also a heuristic.
Window Caption can be change so this also looks like a hack.. But still it
is something..

Still I'm thinking of some more universal solution, which doesn't depend
on Caption strings but maybe at least on HWND comparison? Maybe there is
any? If only there was an Application.Hwnd in Excel/PowerPoint and if only
it would be never equal to GetActiveWindow() while clicking into EMBED
application and equal to GetActiveWindow() in every other case.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top