Command Bar Controls in PP 97

R

Roderick O'Regan

Recently, I've had a lot of help from MVP's (and very grateful I am, too) as
well as reading from VBA help. This allowed me to create a procedure to open
a dialog box from which I could insert a picture. However, this only works
in PP 2002 upwards.

I now need to create the same thing to work in PP97 and 2000.

So I went back to VBA help in PP and found that the routine below added the
appropriate buttons to a floating toolbar called "Custom":

Dim customBar As CommandBar
Dim newButton As CommandBarButton
Set customBar = CommandBars.Add("Custom")
Set newButton = customBar.Controls _
.Add(msoControlButton, CommandBars("Edit") _
.Controls("Cut").Id)
Set newButton = customBar.Controls _
.Add(msoControlButton, CommandBars("Edit") _
.Controls("Copy").Id)
Set newButton = customBar.Controls _
.Add(msoControlButton, CommandBars("Edit") _
.Controls("Paste").Id)
customBar.Visible = True

Tested the above in PP 2000 and it worked perfectly!

So, following the same principle as above I added another few lines as
follows:

Set newButton = customBar.Controls _
.Add(msoControlButton, CommandBars("Insert") _
.Controls("From File...").Id)
customBar.Visible = True

The "From File..." wording of the control I took from the
Customize|Commands|Insert list. It failed when tested. With error number 5.

I replaced "From File..." with "Save As..." (same structure) and that worked
perfectly. The Save As... dialog box opened.

Is there anyone, please, who could tell me how to open - programmatically in
VBA in PP 97 - a dialog box to choose and then insert a picture into a
slide?

I've chased around all the FAQ sites for answers but to no avail. I'm
beginning to think it's impossible to do!

Regards

Roderick O'Regan
 
S

Steve Rindsberg

So I went back to VBA help in PP and found that the routine below added the
appropriate buttons to a floating toolbar called "Custom":

Dim customBar As CommandBar
Dim newButton As CommandBarButton
Set customBar = CommandBars.Add("Custom")
Set newButton = customBar.Controls _
.Add(msoControlButton, CommandBars("Edit") _
.Controls("Cut").Id)

This adds a new button that in effect duplicates the existing Cut button (face
and action)
So, following the same principle as above I added another few lines as
follows:

Set newButton = customBar.Controls _
.Add(msoControlButton, CommandBars("Insert") _
.Controls("From File...").Id)

But there's no built in button with this name or functionality, so there's
nothing for PPT to add.
I replaced "From File..." with "Save As..." (same structure) and that worked
perfectly. The Save As... dialog box opened.

But there IS a Save As button. See the pattern? ;-)
Is there anyone, please, who could tell me how to open - programmatically in
VBA in PP 97 - a dialog box to choose and then insert a picture into a
slide?

Visit this site and search on "common dialog"
Lots of first-rate examples
http://vbnet.mvps.org/

Using the common dialog is a bit more work but it'll work in any version of PPT
from 97 on. And the same code will work in the other office apps and VB as
well.
 

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