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
 
S

Steve Rindsberg

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.

To bounce something of what Austin's said: it may be that the default actions
for some OLE objects are hardcoded in PPT (sounds would logically default to
Play in PPT, regardless of system settings). But perhaps PPT would respect
system settings for other file types that it has no hardcoded defaults for.

You can set the default verb in Windows Explorer, Tools, Folder Options, File
Types tab, choose your file type, click Advanced; choose a verb, click Set
Default. Might be worth experimenting around with various filetypes that are
not likely to be hard coded in PPT, see if you can change the defaults for them
thataway.
 
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!
 
S

Steve Rindsberg

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).

Ah, but those are not built in. They call the Windows MCI media player or the
Windows Media Player.

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.

A possibly lunatic thought: define a Play verb that performs the default
action you prefer (even if that doesn't happen to be Play in the usual sense of
the word)

Please understand that I'm speaking from near-total ignorance of OLE servers.
What I'm suggesting here may be ... ah. Well, I did qualify it with that
"possibly lunatic" thingie. ;-)
 
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?
 
S

Steve Rindsberg

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.

Right, or at least so long as the media objects arrived in PPT via Insert, Sounds
& Movies, Etc, Etc rather than Insert Object.

With inserted objects, you get a generic OLE object; then the behavior seems to be
(based on only a few observations, mind you):

- If the object has a Play verb, Play becomes the action setting when the object
is clicked

- If the object doesn't have a Play verb, NO action setting is assigned; it's left
to the user to choose the verb they want from the ones the object makes available.

That fits with what you've mentioned below as well.

Except that I take it PPT isn't automatically using your OLE server's Play verb?
After you've inserted one of your objects, what do you get for the shape's action
setting?
 
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
 

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