ole object default action

B

Bob

Does anyone know how to make an ole server object default itself to
having one of its verbs automatically set as the "object action" under
the "Mouse Click" tab in "Action Settings" in PowerPoint?

I know it can be done on the PowerPoint side via a vbs macro like
this:
ActiveWindow.Selection.ShapeRange.ActionSettings(ppMouseClick).ActionVerb
= "play"

but I need to have it done automatically just when adding the object
to the slide, just like a "Sound Recorder Document" object and other
ole server objects I've seen do.

Any ideas? Please be specific. Thanks!
 
A

Austin Myers

Right click the object, got the animations pane, and select Object Actions.
There you can set it to activate automatically. Is that what you want?


Austin Myers
MS PowerPoint MVP Team

Provider of PFCMedia, PFCPro, PFCExpress
http://www.pfcmedia.com
 
B

Bob

Thanks for the reply, but actually no. I don't mean animation, I'm
talking about the action that happens on click. To set it manually,
you'd normally have to:
- right-click the object
- select "&Action Settings..."
- highlight "Object &action"
- drop down and choose the ole verb you want.

What I want to do is register my ole server's verbs on installation
somehow such that when the user inserts the object into PowerPoint, it
starts out with one of the verbs as the on-click action, without the
user having to go through the above steps.

To see an example of what I mean, click Insert->Object... and select
"Wave Sound". It adds the object and opens the Windows sound
recorder. When you close the recorder and return to PowerPoint, if
you follow the above steps you'll see that the "Object &action" radio
is already highlighted and the "Play" verb has already been selected
from the dropdown.

How did PowerPoint know to auto-select that verb as the on-click
action?
 
B

Bob

Again, I'm not talking about animation.

The "play" verb is just another verb exposed by the Sound Recorder
Document (or "Wave File") object class called "MPlayer" as you'll see
under the HKCR\MPlayer\protocol\StdFileEditing\verb registry key.
You'll notice there are three verbs there: 0 (&Play), 1 (&Edit), and 2
(&Open). Somehow PowerPoint is picking "Play" as the default on-click
action.

I'm trying to figure out how PowerPoint decides to pick that verb when
"Wave File" objects are inserted, when for most other ole server
classes (e.g. Microsoft Equation 3.0) it leaves it defaulted to "none"
for the on-click action.

Any other thoughts? Again thanks for your help so far.
 
A

Austin Myers

Again, I'm not talking about animation.

Yes you are, you just don't know it. <g>

As far as PPT is concerened, do verbs like "play" are an animation and it
treats them as such. In fact in PPT XP forward eveything that happens is
related to the animation settings and the timeline.

As an example:

You insert a media file---

Set clockMovie = ActivePresentation.Slides(1).Shapes _
.AddMediaObject(FileName:="C:\WINNT\clock.avi", _
Left:=20, Top:=20)

Then you use the animation Settings to access the DoVerbs for the media.

With clockMovie.AnimationSettings.PlaySettings
.PlayOnEntry = True
.PauseAnimation = False
.HideWhileNotPlaying = True
End With
I'm trying to figure out how PowerPoint decides to pick that verb when
"Wave File" objects are inserted, when for most other ole server
classes (e.g. Microsoft Equation 3.0) it leaves it defaulted to "none"
for the on-click action.

Hard coded in PPT to handle different OLE objects differently.

Now if you wanted to you could control the verb via code. In this example
PPT will fire off the default verb for the object on a slide. (assuming
it's an OLE object.)

With ActivePresentation.Slides(1).Shapes(1)
If .Type = msoEmbeddedOLEObject Or _
.Type = msoLinkedOLEObject Then
.OLEFormat.DoVerb
End If
End With

To find what action verbs are exposed by the object you can do something
like:

With ActivePresentation.Slides(1).Shapes(1).OLEFormat
For Each v In .ObjectVerbs
MsgBox v
Next
End With


If you aren't certain which objects are OLE you might do something like:

For Each sld In ActivePresentation.Slides
For Each sh In sld.Shapes
If sh.Type = msoLinkedOLEObject Then
Do something here with your code
End If
Next
Next



Austin Myers
MS PowerPoint MVP Team

Provider of PFCMedia, PFCPro, PFCExpress
http://www.pfcmedia.com
 
B

Bob

I'm the auther of the ole server application. I'm trying to figure
out how to design its installer so that when a user inserts it into
PowerPoint, the shape's ActionSettings(ppMouseClick).ActionVerb
defaults to the verb I want.

I'm not trying to be argumentative Austin, but I still insist I'm not
talking about animation. Your sample code keeps referring to the
shape's AnimationSettings properties, but my concern involves only the
ActionSettings(ppMouseClick) properties.

I could do it from vba script for sure within PowerPoint (see my
original post), but that doesn't help because it needs to work
automatically for anyone who wants to use my ole server application.
So it's not limited to one presentation.

I liked your idea Steve about setting the default verb. Unfortunately
this didn't do the trick. It makes it so double-clicking a file of my
ole server's type results in the "play" verb being executed, but it
doesn't change what PowerPoint does when the object is added. Also I
suppose it's possible that some OLE objects are hardcoded in
PowerPoint, but I can find no documentation to suggest that's true,
and it really seems unlikely when PowerPoint has its own built-in
media objects (the "Movies and Sounds" pop-out menu). Can you think
of any way to try to find out if it's true or not? I've tried adding
all kinds of ole objects, and very few of them have the an action set
automatically like I want, but that makes sense because most objects
don't have an audio component, so their visual aspect is the only
point of their presense in the slide which means they usually don't
need to do anything on click. See what I'm saying?

Anyway thanks for all the ideas! Any other thoughts? I know this is
a pretty tricky situation, but any more comments or suggestions are
greatly appreciated.
 
A

Austin Myers

Bob,

I think we are talking across each other. <g> Perhaps if you could tell us
what your application server does and how you want it to behave, we could
offer better answers.
 
B

Bob

Excellent idea.

My ole server application is very simple: it produces audio output
directly to the system speakers based on a few properties given by the
user.

Previously I'd been recording the audio manually based on the user's
request (i.e. he calls me up on the phone and says, "Hey Bob can we go
back to that last one but add a 'ping' at the end?" so I go back, re-
record the mp3 through a program I've already written, but this time
include an extra "ping" at the end). Then I deliver the mp3 to the
user so he can embed it in his presentation by the standard mechanism:
that is Insert -> Movies and Sounds -> Sound from File... and then
browsing to the mp3.

So to make the round trip a lot better for my client, I wrote an ole
server application based on the same app I already had for recording
the audio, but instead of recording it I made it just play directly to
the system speakers. Now he can embed an object in his presentation
(by way of Insert -> Object...), make whatever changes he wants (i.e.
adding a "ping" on the end) right then and there, and then play the
audio by way of the "play" verb right from PowerPoint.

So there you have it. You can understand why I didn't explain it
earlier, it's a little bit strange with the custom audio behavior.
But I'm sure you can also see why I want to make it "feel" like a
normal sound clip to the user. It's working great, except when adding
new ones, the user still has to right-click on it afterward and set
the Action Settings to "play" on click. Granted that's a whole lot
better than having to call me and go through that crazy process, but
I'd like to eliminate this one last annoyance for the client if I can.

Thanks!
 
A

Austin Myers

Bob said:
Excellent idea.

My ole server application is very simple: it produces audio output
directly to the system speakers based on a few properties given by the
user.

Previously I'd been recording the audio manually based on the user's
request (i.e. he calls me up on the phone and says, "Hey Bob can we go
back to that last one but add a 'ping' at the end?" so I go back, re-
record the mp3 through a program I've already written, but this time
include an extra "ping" at the end). Then I deliver the mp3 to the
user so he can embed it in his presentation by the standard mechanism:
that is Insert -> Movies and Sounds -> Sound from File... and then
browsing to the mp3.

So to make the round trip a lot better for my client, I wrote an ole
server application based on the same app I already had for recording
the audio, but instead of recording it I made it just play directly to
the system speakers. Now he can embed an object in his presentation
(by way of Insert -> Object...), make whatever changes he wants (i.e.
adding a "ping" on the end) right then and there, and then play the
audio by way of the "play" verb right from PowerPoint.


Sorry but I am still confused here Bob. What is actually playing the audio?
Your app or PPT? If it is PPT (which calls the MCI player) then you MUST
use the animation settings because PPT has no clue what to do with it if you
don't.
 
B

Bob

What is actually playing the audio? Your app or PPT?

My app plays the audio. PowerPoint sends it the "play" verb and it
generates the custom audio on the fly and plays it directly to the
speakers, no involvement from PowerPoint.
 
B

Bob

and it really seems unlikely when PowerPoint has its own built-in
Ah, but those are not built in. They call the Windows MCI media player or the
Windows Media Player.

Perhaps "built in" was the wrong choice of words. What I meant was
that they're known to PowerPoint as "media objects" so it can play,
pause, loop, whatever. That's as opposed to "ole objects" which are
black boxed from PowerPoint's perspective, and upon which it only can
call that object's published verbs.

Also, further evidence of my assertion that PowerPoint treats any OLE
object as a black box is an article from Microsoft (http://
msdn2.microsoft.com/en-us/library/aa168127(office.11).aspx) in which
it describes how to add audio and video files as OLE objects instead
of as media objects. It says, "Once you add the media file to your
presentation as an OLE object, PowerPoint treats it as any other OLE
object; PowerPoint does not recognize it as a media object. The
actions the media file can perform are limited to the verbs that
particular OLE class exposes. For example, media files inserted as
Microsoft Media Player OLE objects expose the following three verbs:
play, edit, and open."

And given that PPT's purpose in life is creating presentations, it seems
logical that it might be hardcoded to default to Play, as long as a Play verb
is available.

Coincidentally the verb my OLE server exposes IS the verb "play", but
as the above excerpt confirms, PowerPoint doesn't seem to care what
the verbs are.

I thank you again for your continuing efforts! Any other thoughts
come to mind for solving this frustrating problem?
 
B

Bob

Except that I take it PPT isn't automatically using your OLE server's Play verb?

correct, that's the exact problem.

After you've inserted one of your objects, what do you get for the shape's action
setting?

After one of my objects has been inserted, the shape's action settings
are set to "None". If I manually change them to "Object action" I can
then select "Play" from the dropdown list, but that's the manual step
I'm trying to make automatic.
 
A

Austin Myers

Bob said:
My app plays the audio. PowerPoint sends it the "play" verb and it
generates the custom audio on the fly and plays it directly to the
speakers, no involvement from PowerPoint.

Ok, if I understand what you are saying, PowerPoint can only send the play
verb from the animation settings. (Or with a WithEvents trap that you build
and handle).
 
B

Bob

Can you post the code you are using to insert the OLE object?

I'm not doing it from code. I'm just clicking Insert -> Objects...
and selecting my ole application class.
 
A

Austin Myers

I'm not doing it from code. I'm just clicking Insert -> Objects...
and selecting my ole application class.


We are going around the same bush again. <g> Lets take a different
approach.

If I were to insert say the Windows Media Player with a link to a wav file,
it would not simply play on its own in PPT. PPT MUST do something to fire
it off or your code must do it. Normally I would use PPTs animation
settings for an OLE object and then set the animation to activate. At that
point the code I use for the Media Player would have to jump in and issue
the play command (or what ever I wanted it to do.) The other alternative
would be to build a WithEvents module and fire my code from say the
NextSlide or NextBuild events.

The other obvious method you might use is the "OnClick" event in your code.
Click the object, capture that click and do with it as you wish. In fact,
that would probably be the easiest solution.


Austin Myers
MS PowerPoint MVP Team

Provider of PFCMedia, PFCPro, PFCExpress
http://www.pfcmedia.com
 
A

Austin Myers

But look at what happens when you insert a WAV as an object. Action
setting's
set to Play automatically, and unless I'm WAY off the mark, that's what
Bob's
after. No code other than what's in the inserted object and/or OLE
server
that owns it. That about right, Bob?

Ok, I think I see what Bob is after. (Yeah I am slow but eventually I catch
on. <g>)

Following up with what you said Steve, it appears the only objects that
behave in this manner are wav and mid files. In fact when I insert a wav as
an object I am given the speaker icon on the slide which leads me to believe
(s.w.a.g.) that PPT recognizes the file type internally and handles it
accordingly. Mid files are automatically given the Sound Recorder icon.

Hmmm, experimenting a little more and it seems this only holds true for wav
files that are PCM (Pulse Code Modulation) based. Other types of wav files
do not generate the speaker icon or the Play action setting. Again its a
s.w.a.g but that leads me to believe PPT is reading the file header and if
it meets the set criteria goes ahead and assigns the play action setting.

I see nothing in the object model that would allow us access to this . :-(



Austin Myers
MS PowerPoint MVP Team

Provider of PFCMedia, PFCPro, PFCExpress
http://www.pfcmedia.com
 
B

Bob

But look at what happens when you insert a WAV as an object. Action
setting's set to Play automatically, and unless I'm WAY off the mark, that's
what Bob's after. No code other than what's in the inserted object and/or
OLE server that owns it. That about right, Bob?

Thank you, and Austin too, for all the ideas, and for sticking with me
on this. Steve your assessment (above) of my situation is EXACTLY
right.
Hmm. Assuming you've got Visual Studio installed, maybe try poking around with the
included Ole/Com viewer; compare what your server looks like to it vs what a server
that automatically creates a Play action looks like. Afraid I've no clue what to
look for exactly, but maybe you'll see something to trigger the Aha! experience.

I have studied the OLE viewer, and unfortunately I have been unable to
discern a meaningful difference between my ole server and the windows
sound recorder.

Along the way in this whole investigation I started to wonder if maybe
the windows sound recorder ole server itself, on instantiation,
attempts to figure out whether it's being embedded in PowerPoint, and
if so navigates the PowerPoint object model to find "itself" as a
shape within the presentation, and then sets that shape's
ActionSettings(ppMouseClick).ActionVerb to "play".

I tried this and it works! Here's how I did it (from the point of
view of my ole server code):
- queryinterface myself for IOleObject
- call IOleObject::GetClientSite() to get the IOleClientSite that
holds me
- call IOleClientSite::GetContainer() to get the IOleContainer for
that site.
- queryinterface the IOleContainer for the PowerPoint
"_Presentation"
interface (PowerPoint::_Presentation) to see if it supports it (if so
I think it's safe to I assume I'm embedded in a PowerPoint
presentation)
- Using the PowerPoint object model, I'm then able to sift through
all
the slides of the presentation, and all the shapes on each slide.
For
each shape I
- check its type to see if the shape is an ole embedded object
(Type == msoEmbeddedOLEObject)
- if so I get the Object property of the OLEFormat container of
the shape, and I queryinterface for its IUnknown *. finally I
compare
that pointer to my own IUnknown *. If they match, then I have "found
myself."


I know, it's crazy isn't it!?!? It works, but it's less than ideal
because, while it's reasonably quick for a presentation with only a
few slides, a large presentation hesitates a bit when you add a new
object because it has to search through every slide, which is uncool.
It's not outlandishly slow, but noticeable in some cases and I'm not
happy about that.

So I posted in the microsoft.public.win32.programmer.ole group to see
if anyone knew how I could just step up one level from my ole object
itself to get the shape that contains it instead of the above round-
about search process.

In the mean time I'm going to stick with this approach unless you guys
can conceive of either a better way to do the above, or MUCH more
preferably, a way of registering my "play" verb so that PowerPoint
simply says, "hey this object should 'play' when clicked," whenever a
new object of my type is added.

Again thank you for all your help!
 
B

Bob

I wonder if you can navigate from the object upward through the chain of .Parent
properties.

For example, if you have a reference to the shape, then it's .Parent is the slide it's
on and so forth.

The trouble I'm having with that is getting "my" Shape to begin with.
My ole server object is all my code, and the powerpoint Shape object
is the thing in the PowerPoint object model that contains me, but it
seems it's entirely up to the container application (PowerPoint) as to
whether (and how) it lets outsiders gain access to its object model.
And even though my object is embedded in PowerPoint, it's still
technically an "outsider" and I have not been able to discover a way
(other than the "round-about way" described in my prior post) to get
from my embedded object to the Shape that contains it.

It's very disappointing, but I guess I should be happy with what I've
got. We'll see if anyone over in the programmer.ole group has any new
ideas. I think there MUST be a way, and I imagine SOMEONE out there
would look at the problem and say, "Duh of course you just have to
<insert answer here>," so it's just a matter of tracking down that
person.

Thanks for your help. If you ever run into someone you think might
fit the above description, send 'em my way!!
 

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