Programming: Toolbar and Palette Events?

B

Brian

Hello All,

I am currently working on an accessibily program and would like
to know if it is possible to receive events from the toolbar and the
Palette's?

What I would like access to is the fact that the application user has
selected an item either on the toolbar or a palette.

Using the Cocoa accessibility API, I can gain access to all of the
menubar
options, but I can not get notifications if a option (such as Bold) is
selected
any other way.
From what I have read on various online resources, there are PPT events
that
I can listen on, but I have not found a complete list of these events
yet. Where
can I find these?

Thanks for any help

Brian
 
J

Jim Gordon MVP

Hi Brian,

The PowerPoint object model is available from PowerPoint help when in the
Visual Basic Editor. To get to the Visual Basic editor use View > Toolbars >
Visual Basic then click the Visual Basic Editor button.

When the editor is running enter the phrase "Object Model" in the search box
and you will find a wealth of information. Also search on the word "event."

In the visual basic editor is an object browser. Put specific terms into the
search box there and you will find great detail about each item's
properties, methods, etc. The object browser and help each have code
examples. If the object browser doesn't return a help topic be sure to
search help manually because integration between the two is not perfect.

There are various ways of using the object model. You can control PowerPoint
via Visual Basic, AppleScript and RealBasic. You might need to combine these
ways depending upon your goal.

Check out this help topic in the visual basic editor:
Bold, Italic, Size, StrikeThrough, Underline, Weight Properties

Please consider the future of Office. Office 2004 will continue to work with
visual basic, but Office 12 (the next version - it's actual name has yet to
be determined) will not have a visual basic editor and visual basic will not
work in Office 12.

In Office 12 you will be able to use the PowerPoint object model via
AppleScript and RealBasic. So if you want to build an application that works
for Office 2004 and Office 12 then don't use Visual Basic or AppleScript's
"Do Visual Basic." The Visual Basic compiler will not be available in Office
12. Obviously any of the new Leopard-only Cocoa enhancements will work only
in Leopard.

If you are at MacWorld 2007 SanFrancisco be sure to drop by the Microsoft
booth. You'll be able to meet with MVPs and Microsoft PopwerPoint
developers, testers, product managers, etc. The people manning the booth
will be taking turns, so it is pot luck as to who will be there at any given
moment.

Please feel free to post any questions or comments you may have along the
way to this newsgroup. You are always welcome here to ask questions and
provide answers to other postings.

-Jim Gordon
Mac MVP


Hello All,

I am currently working on an accessibily program and would like
to know if it is possible to receive events from the toolbar and the
Palette's?

What I would like access to is the fact that the application user has
selected an item either on the toolbar or a palette.

Using the Cocoa accessibility API, I can gain access to all of the
menubar
options, but I can not get notifications if a option (such as Bold) is
selected
any other way.

that
I can listen on, but I have not found a complete list of these events
yet. Where
can I find these?

Thanks for any help

Brian

--
Jim Gordon
Mac MVP

MVPs are not Microsoft Employees
MVP info
 
S

Steve Rindsberg

Brian said:
Hello All,

I am currently working on an accessibily program and would like
to know if it is possible to receive events from the toolbar and the
Palette's?

Not using VBA, I'm afraid. PPT's VBA implementation doesn't get events until
VBA version 6, but Mac Office is still on VBA version 5. No events in PPT, and
the next version won't even have VBA.

PPT may expose different methods/properties/events to Applescript than to VBA;
if so, that might be the answer. Poke around this and other newsgroups in the
neighborhood and see if you can turn up Paul Berkowitz. If anyone knows, he
would.


What I would like access to is the fact that the application user has
selected an item either on the toolbar or a palette.

Using the Cocoa accessibility API, I can gain access to all of the
menubar
options, but I can not get notifications if a option (such as Bold) is
selected
any other way.

that
I can listen on, but I have not found a complete list of these events
yet. Where
can I find these?

Thanks for any help

Brian

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

Jim Gordon MVP

Hi,

I think this is a relevant code sample from PowerPoint 2004 help:

CommandBarEvents Property Example
The following example uses code including the CommandBarEvents property to
support any code to handle a mouse click on a command bar.
Private WithEvents ce As CommandBarEvents

Sub Test()
Dim c As CommandBarControl
Set c = Application.VBE.CommandBars("Tools").Controls(1)
Set ce = Application.VBE.Events.CommandBarEvents(c)
End Sub

Private Sub ce_Click(ByVal CommandBarControl As Object, Handled As Boolean,
_
CancelDefault As Boolean)
' Put event-handling code here
End Sub
----
The office object model is accessible to AppleScript. It is also available
to any 3rd part application that uses OLE Automation, such as RealBasic.
----
More from PowerPoint help:

When an application supports Automation, the objects the application exposes
can be accessed by Visual Basic. Use Visual Basic to manipulate these
objects by invoking methods on the object or by getting and setting the
object's properties. For example, you can create an Automation object named
MyObj and write the following code to access the object:
MyObj.Insert "Hello, world." ' Place text.
MyObj.Bold = True ' Format text.
#If Mac Then ' Check your platform constant
MyObj.SaveAs "Macintosh HD:Applications:Users:Shared:TESTOBJ.DOC" '
Save the object (Macintosh).
#Else
MyObj.SaveAs "C:\WORDPROC\DOCS\TESTOBJ.DOC" ' Save the object
(Windows).
#End If
Use the following functions to access an Automation object:
Function Description
CreateObject Creates a new object of a specified type.
GetObject Retrieves an object from a file.
When an application supports Automation, the objects the application exposes
can be accessed by Visual Basic. Use Visual Basic to manipulate these
objects by invoking methods on the object or by getting and setting the
object's properties. For example, you can create an Automation object named
MyObj and write the following code to access the object:
MyObj.Insert "Hello, world." ' Place text.
MyObj.Bold = True ' Format text.
#If Mac Then ' Check your platform constant
MyObj.SaveAs "Macintosh HD:Applications:Users:Shared:TESTOBJ.DOC" '
Save the object (Macintosh).
#Else
MyObj.SaveAs "C:\WORDPROC\DOCS\TESTOBJ.DOC" ' Save the object
(Windows).
#End If
Use the following functions to access an Automation object:
Function Description
CreateObject Creates a new object of a specified type.
GetObject Retrieves an object from a file.

----

Although the visual basic editor and the visual basic compiler will be
removed from Microsoft Office, it is possible that the OLE Automation will
not die because OLE automation does not need the VBA compiler. If you were
to use RealBasic your code is compiled by and in RealBasic, not VBA even
though RealBasic uses VBA OLE animation syntax to run VBA code. It would be
almost the same as running PowerPoint from Word or Excel today in 2004's
Visual Basic environment.

The upside to this is the when you make a RealBasic compiled application to
run PowerPoint on the Mac, if you're careful your code should work on the PC
side, too. There are differences in the Mac and Windows office object
models, and you will have to take those into account when using OLE
Automation just as you would in the visual basic editor.

-Jim Gordon
Mac MVP

Not using VBA, I'm afraid. PPT's VBA implementation doesn't get events until
VBA version 6, but Mac Office is still on VBA version 5. No events in PPT,
and
the next version won't even have VBA.

PPT may expose different methods/properties/events to Applescript than to VBA;
if so, that might be the answer. Poke around this and other newsgroups in the
neighborhood and see if you can turn up Paul Berkowitz. If anyone knows, he
would.




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

--
Jim Gordon
Mac MVP

MVPs are not Microsoft Employees
MVP info
 
S

Steve Rindsberg

Hi,

I think this is a relevant code sample from PowerPoint 2004 help:

This appears to be directed at the VBA IDE rather than PPT itself; the two expose
different OMs and events. I'm not sure this'd work in PPT itself (and don't have
2004 installed to test with).
 
J

Jim Gordon MVP

Hi,

And I'm at Macworld and am falling asleep as I type this, so I can't try it
either.

Blurry brain tonight. Sorry.

-Jim Gordon
Mac MVP


This appears to be directed at the VBA IDE rather than PPT itself; the two
expose
different OMs and events. I'm not sure this'd work in PPT itself (and don't
have
2004 installed to test with).

--
Jim Gordon
Mac MVP

MVPs are not Microsoft Employees
MVP info
 
J

Jim Gordon MVP

As it turns out I'm the PowerPoint MVP at the MacTech booth in just a few
hours. Yesterday I was Excel.


No problem. But hint: make a point of going to the MacTech booth and asking
what they know about VBA and programmability in upcoming Mac Office versions.
PaulB's been very busy.



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

--
Jim Gordon
Mac MVP

MVPs are not Microsoft Employees
MVP info
 
S

Steve Rindsberg

And I'm at Macworld and am falling asleep as I type this, so I can't try it
either.

Blurry brain tonight. Sorry.

No problem. But hint: make a point of going to the MacTech booth and asking
what they know about VBA and programmability in upcoming Mac Office versions.
PaulB's been very busy.

-Jim Gordon
Mac MVP

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

Steve Rindsberg

As it turns out I'm the PowerPoint MVP at the MacTech booth in just a few
hours. Yesterday I was Excel.

Useful guy. <g>

Make sure you get a copy of the book!
 
P

Paul Berkowitz

Not using VBA, I'm afraid. PPT's VBA implementation doesn't get events until
VBA version 6, but Mac Office is still on VBA version 5. No events in PPT,
and
the next version won't even have VBA.

PPT may expose different methods/properties/events to Applescript than to VBA;
if so, that might be the answer. Poke around this and other newsgroups in the
neighborhood and see if you can turn up Paul Berkowitz. If anyone knows, he
would.

No events in AppleScript. (AppleScript Studio is rife with events, but only
for your own apps you make with Studio - not for other apps like PPT.) I
don't think they'll be adding them either - they are staying completely away
from anything that could ever possibly be a security risk, including
embedding scripts in documents, automacros, and events.

But it appears (no official word yet - I'm sure RB is waiting for Office
2008 to be available in beta so they can check and text) that RealBasic
might still be able to work with Office 2008. If so, I'm pretty sure you
could get events using RB. You'll need to wait for an announcement from RB,
but that's bound to come before Office 2008 itself.

--
Paul Berkowitz
MVP MacOffice
Entourage FAQ Page: <http://www.entourage.mvps.org/faq/index.html>
AppleScripts for Entourage: <http://macscripter.net/scriptbuilders/>

Please "Reply To Newsgroup" to reply to this message. Emails will be
ignored.

PLEASE always state which version of Microsoft Office you are using -
**2004**, X or 2001. It's often impossible to answer your questions
otherwise.
 
J

Jim Gordon MVP

Hi again,

Just before leaving for MacWorld I downloaded and installed the new
RealBasic 2007 in trial mode.

Their web site indicates that RealBasic is compatible with Office v.X but
doesn't mention Office 2004, much less Office 2008.

Nonetheless in their documentation they offer a little bit of code that they
said would let us know whether or not the application can be controlled via
RealBasic 2007. I ran the code on Office 2004 and the result was positive,
so maybe they've done something to update it.

Paul was kind enough to offer pre-release copies of his upcoming book, and I
read most of it on the way home from MacWorld. I'm certain it will be an
essential reference for many VB developers. There was lots of mention of
help from some guy named Steve.

In the next few days I hope to try RealBasic 2007 with Office 2004. It looks
very promising at the moment.

Office 2008 will lack the visual basic code editor and compiler. Without the
editor you can't write VBA code. Without the compiler you can't run vba
code, which means all existing VBA macros will stop working.

RealBasic is a code editor and compiler. Although it is a different language
and is compiles its code differently from Microsoft's Visual Basic compiler,
the RealBasic compiled code can talk to Office's OLE Automation using
Microsoft's VBA code syntax.

I'm not too quick with OLE Automation, so it will take me a while to try
some things, such as making a userform or manipulating a graph.

As Paul said, it is too soon to tell whether or not OLE Automation will
continue to work in Office 2008.

If anyone has some OLE Automation code for me to try I'm game.

-Jim Gordon
Mac MVP


No events in AppleScript. (AppleScript Studio is rife with events, but only
for your own apps you make with Studio - not for other apps like PPT.) I
don't think they'll be adding them either - they are staying completely away
from anything that could ever possibly be a security risk, including
embedding scripts in documents, automacros, and events.

But it appears (no official word yet - I'm sure RB is waiting for Office
2008 to be available in beta so they can check and text) that RealBasic
might still be able to work with Office 2008. If so, I'm pretty sure you
could get events using RB. You'll need to wait for an announcement from RB,
but that's bound to come before Office 2008 itself.

--
Jim Gordon
Mac MVP

MVPs are not Microsoft Employees
MVP info
 
S

Steve Rindsberg

Paul was kind enough to offer pre-release copies of his upcoming book, and I
read most of it on the way home from MacWorld. I'm certain it will be an
essential reference for many VB developers. There was lots of mention of
help from some guy named Steve.

He spells "hindrance" oddly, doesn't he? ;-)
I'm not too quick with OLE Automation, so it will take me a while to try
some things, such as making a userform or manipulating a graph.

Once you work out how to do it in the "native vba" it's fairly easy to translate
to automation, at least in other vb/vba variants:

Instead of

Code
That
Works
In
App
Natively

You use

Code to get a reference to the app object
With app object
Code
That
Works
In
App
Natively
End with

Applescript is very different, as you'll have seen from Paul's book, but RealBasic
might be more like vb/vba.

You'd do any needed forms in the coding environment (ie, RealBasic in your case).
Forms are a feature of VBA itself, not PPT/other apps. Once VBA goes away, VBA
forms will go with it.
 

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