Application property

C

Calin

Hello

I have the following problem related to PowerPoint 2003 (perhaps it happens
also in previous versions but I didn't tested yet).

I tried to obtain the PowerPoint application object using the Application
property of a command bar button like this :

Dim button As CommandBarButton
Set button = toolbar.Controls.Item(1) // where toolbar is a valid command
bar

Dim ppt As Application
Set ppt = button.Application

I get an error Run Time Error 80004005 , Method 'Application' of object
'_CommandBarButton' failed.

First I tried this using a COM Addin written in C++, I noticed the problem,
then I tried in VBA and it is the same behaviour.

Any help will be very appreciate. Thanks.
 
S

Steve Rindsberg

Hello

I have the following problem related to PowerPoint 2003 (perhaps it happens
also in previous versions but I didn't tested yet).

I tried to obtain the PowerPoint application object using the Application
property of a command bar button like this :

Dim button As CommandBarButton
Set button = toolbar.Controls.Item(1) // where toolbar is a valid command
bar

Dim ppt As Application
Set ppt = button.Application

What's "toolbar" in this case? Assuming it's a reference to a specific toolbar
in the PPT commandbars collection, how did you get the reference? It seems
you've have had to have a reference to the PPT application to get there in the
first place.
 
C

Calin

Hi Steve

you're right. I had a reference to the PPT application and that's how I get
the reference to the "toolbar" which is the "Standard" toolbar. But after
that I tried to obtain the application reference from the button reference
and it doesn't work. I also saw in debugger (in Watch window) that for the
button object, the Application property returns an error.

In my project, written in C++, I have a toolbar button sink object and I get
on Click event handler, the button interface pointer as a parameter. And I
try to get the application interface using the button interface (the
Application property). And it fails (very bad, PPT crashes). That's why I
tried that piece of VBA code to see if it works in VBA. But it doesn't. It
is a known error ? Do you have any ideea how to handle it ?

Thanks, Calin
 
S

Steve Rindsberg

Hi Steve

you're right. I had a reference to the PPT application and that's how I get
the reference to the "toolbar" which is the "Standard" toolbar. But after
that I tried to obtain the application reference from the button reference
and it doesn't work. I also saw in debugger (in Watch window) that for the
button object, the Application property returns an error.

... though the object browser shows it as an available property in some cases.
I can duplicate that here in VBA as well. I'm guessing that it has to do with
the fact that CommandBars is a property of Office and not of PowerPoint. Or
not, depending on which bit of documentation you look at.

I'm afraid I'm at a loss here ...
 
C

Calin

Hm, indeed it is strange that somtimes it is available.
Anyway, I'll try to get the Application value from elsewhere.

Thanks a lot, Calin
 

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