Supported Application Events in VBA

E

Eric Crichlow

Okay, I've tried searching through old messages for my answer first. I
really have. I have seen similar questions asked, and it seems like
the general answer is to check out http://www.rdpslides.com or
http://www.mvps.org/skp/.

I've gotten sample code from one or both of these sites and tried
it but I still run into a problem. The Application object in the Mac's
version of VBA doesn't support any events, and it's that object (and
its events) that all of the sample projects rely on.

It seems to me that I've seen some messgaes here (with all of the
searches I've done between here and the Windows PP forum my head is
swirling) that suggest that on the Mac we can write VBA code that
responds to application or presentation level events, like the
presentation changing slides during a slideshow. But damned if I can't
figure out how.

Can someone point me in the right direction?

....Thanx...
....Eric...
 
S

Steve Rindsberg

Eric Crichlow said:
Okay, I've tried searching through old messages for my answer first. I
really have. I have seen similar questions asked, and it seems like
the general answer is to check out http://www.rdpslides.com or
http://www.mvps.org/skp/.

I've gotten sample code from one or both of these sites and tried
it but I still run into a problem. The Application object in the Mac's
version of VBA doesn't support any events, and it's that object (and
its events) that all of the sample projects rely on.

Anything that does event handling, yes. That's supported in PPT 2000 and up
under Windows, but not on any Mac version, sorry to say.
It seems to me that I've seen some messgaes here (with all of the
searches I've done between here and the Windows PP forum my head is
swirling) that suggest that on the Mac we can write VBA code that
responds to application or presentation level events, like the
presentation changing slides during a slideshow. But damned if I can't
figure out how.

Not with VBA, at least not to my knowledge.

================================================
Steve Rindsberg, PPT MVP
PPT FAQ: www.pptfaq.com
PPTools: www.pptools.com
================================================
 
J

James

The document from microsoft indicate that office automation is pretty much
similar on Mac to that on Windows. But, I did not see anything like event
trap is documented. Does anyone knows whether this is just undocumented or
undoable?

Best,

James
 
J

Jim Gordon MVP

These events and more are available in PowerPoint

Click Event:
Cancel Property
Change Event
DblClick Event
Default Property
Enabled Property
MouseDown, MouseUp Events
Value Property

A quick trip to Help in the visual basic editor (Tools > Macro > Visual
Basic Editor) will reveal what you need to know. Just search on the word
"event."

-Jim
 
S

Steve Rindsberg

These events and more are available in PowerPoint

These are all events tied to controls, no?
I don't think PPT/Mac supports app level events (opening/closing/printing
slides, selecting shapes and so on) does it?
Click Event:
Cancel Property
Change Event
DblClick Event
Default Property
Enabled Property
MouseDown, MouseUp Events
Value Property

A quick trip to Help in the visual basic editor (Tools > Macro > Visual
Basic Editor) will reveal what you need to know. Just search on the word
"event."

-Jim

================================================
Steve Rindsberg, PPT MVP
PPT FAQ: www.pptfaq.com
PPTools: www.pptools.com
================================================
 
J

Jim Gordon MVP

Well, yes, but no.

According to help:
"Public Statement
Used at module level to declare public variables and allocate storage space.
Syntax
Public [WithEvents] varname[([subscripts])] [As [New] type]
[,[WithEvents] varname[([subscripts])] [As [New] type]] . . .
The Public statement syntax has these parts:
Part, Description, WithEvents (Optional).
Keyword specifying that varname is an object variable used to respond to
events triggered by an ActiveX object. Valid only in class modules. You
can declare as many individual variables as you like using WithEvents,
but you can't create arrays with WithEvents. You can't use New with
WithEvents. ActiveX objects are available only in Microsoft Windows."

So, you can create a Public statement with events on a Mac, except that
the events will be active-X controls. Active-X controls are open source
and have not yet been ported to Macintosh, so none of them will work.

I guess if you want to plan ahead and hope some day active-x will work
on Macs, then go ahead and put them into your code. VB won't choke on
them, but they will not work at all right now.

In case anyone reading this has the ambition and resources to make a
port, here's the Active-X specification:
http://www.opengroup.org/pubs/catalog/ax01.htm

-Jim
 
S

Steve Rindsberg

Well, yes, but no.

IOW, ye can ask but ye shall not receive but neither shall ye be castigated
therefor. ;-)

As I understand it though, this allows you to set up a way of receiving events
from whatever object (external to PPT) you've declared in the As New Type
portion. For example, As New ExcelAPP.

But if the object/application doesn't generate events, there's not much point.
I don't believe that PPT/Mac does (could be wrong, mind you).

So for instance, an addin running w/in PPT couldn't respond to the event that
occurs when the user clicks a shape or prints a file. This wasn't implemented
until VBA 6 in PPT/Windows. Can't do it in PPT97 either (VBA5, y'see). I
think PPT/Mac is still at VBA5 as well, isn't it?
According to help:
"Public Statement
Used at module level to declare public variables and allocate storage space.
Syntax
Public [WithEvents] varname[([subscripts])] [As [New] type]
[,[WithEvents] varname[([subscripts])] [As [New] type]] . . .
The Public statement syntax has these parts:
Part, Description, WithEvents (Optional).
Keyword specifying that varname is an object variable used to respond to
events triggered by an ActiveX object. Valid only in class modules. You
can declare as many individual variables as you like using WithEvents,
but you can't create arrays with WithEvents. You can't use New with
WithEvents. ActiveX objects are available only in Microsoft Windows."

So, you can create a Public statement with events on a Mac, except that
the events will be active-X controls. Active-X controls are open source
and have not yet been ported to Macintosh, so none of them will work.

I guess if you want to plan ahead and hope some day active-x will work
on Macs, then go ahead and put them into your code. VB won't choke on
them, but they will not work at all right now.

In case anyone reading this has the ambition and resources to make a
port, here's the Active-X specification:
http://www.opengroup.org/pubs/catalog/ax01.htm

-Jim

================================================
Steve Rindsberg, PPT MVP
PPT FAQ: www.pptfaq.com
PPTools: www.pptools.com
================================================
 
J

Jim Gordon MVP

Dang! Steve is always right. He just loves to hear it over and over again.

To confirm what Steve postulated: The version of VB in Mac Office is VB5
(well, mostly anyway). Some new objects and methods were added to
accommodate the new animations and animation paths in 2004 along with
some mac specific things, but by and large the whole thing is VB 5.

For sure, any new stuff that was added in VBA version 6 is NOT supported
by Mac Office.

And before you ask, no I don't have a clue what the next version of
Office will have in it. I haven't even heard rumors about VBA for the
next version of Office for Windows, and that would have to exist before
MacBU can even begin to think about what will be in the next version of
Mac Office.

-Jim

--
Jim Gordon
Mac MVP
MVP FAQ
<http://mvp.support.microsoft.com/default.aspx?scid=fh;EN-US;mvpfaqs>


Steve said:
Well, yes, but no.


IOW, ye can ask but ye shall not receive but neither shall ye be castigated
therefor. ;-)

As I understand it though, this allows you to set up a way of receiving events
from whatever object (external to PPT) you've declared in the As New Type
portion. For example, As New ExcelAPP.

But if the object/application doesn't generate events, there's not much point.
I don't believe that PPT/Mac does (could be wrong, mind you).

So for instance, an addin running w/in PPT couldn't respond to the event that
occurs when the user clicks a shape or prints a file. This wasn't implemented
until VBA 6 in PPT/Windows. Can't do it in PPT97 either (VBA5, y'see). I
think PPT/Mac is still at VBA5 as well, isn't it?

According to help:
"Public Statement
Used at module level to declare public variables and allocate storage space.
Syntax
Public [WithEvents] varname[([subscripts])] [As [New] type]
[,[WithEvents] varname[([subscripts])] [As [New] type]] . . .
The Public statement syntax has these parts:
Part, Description, WithEvents (Optional).
Keyword specifying that varname is an object variable used to respond to
events triggered by an ActiveX object. Valid only in class modules. You
can declare as many individual variables as you like using WithEvents,
but you can't create arrays with WithEvents. You can't use New with
WithEvents. ActiveX objects are available only in Microsoft Windows."

So, you can create a Public statement with events on a Mac, except that
the events will be active-X controls. Active-X controls are open source
and have not yet been ported to Macintosh, so none of them will work.

I guess if you want to plan ahead and hope some day active-x will work
on Macs, then go ahead and put them into your code. VB won't choke on
them, but they will not work at all right now.

In case anyone reading this has the ambition and resources to make a
port, here's the Active-X specification:
http://www.opengroup.org/pubs/catalog/ax01.htm

-Jim


================================================
Steve Rindsberg, PPT MVP
PPT FAQ: www.pptfaq.com
PPTools: www.pptools.com
================================================
 
S

Steve Rindsberg

Dang! Steve is always right. He just loves to hear it over and over again.

If not always right, at least willing to argue until everybody else gives up
and goes home? ;-)

In this case, it's just that I'm familiar w/ the differences; I'm always
fighting with making PPT/Windows addins compatible with PPT97 ...also VB5.

IAC, we can agree on raising a glass toward Mtn View and saluting anyone who's
pushing for VB6 in PPT 200n.
To confirm what Steve postulated: The version of VB in Mac Office is VB5
(well, mostly anyway). Some new objects and methods were added to
accommodate the new animations and animation paths in 2004 along with
some mac specific things, but by and large the whole thing is VB 5.

For sure, any new stuff that was added in VBA version 6 is NOT supported
by Mac Office.

And before you ask, no I don't have a clue what the next version of
Office will have in it. I haven't even heard rumors about VBA for the
next version of Office for Windows, and that would have to exist before
MacBU can even begin to think about what will be in the next version of
Mac Office.

-Jim

================================================
Steve Rindsberg, PPT MVP
PPT FAQ: www.pptfaq.com
PPTools: www.pptools.com
================================================
 

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