Programmatically inserting a bitmat into a slide

  • Thread starter Thread starter Primoz Bradac
  • Start date Start date
P

Primoz Bradac

Having posted a question to microsoft.public.office.developer.vba and
getting no answer I'm reposting it here, hopefully with more luck :-)

Here is the problem:

I'm using Office 2003 and automating PPT from Access. Actually I'm
creating a presentation: each slide should represent the contents of a
record from an Access table.

I use ADODB to retrieve the recordset and then put the text fields on a
slide with Layout = ppLayoutTextAndObject.

There is no difficulty putting the text fields of each record onto a
slide with e.g.:

oSlide.Shapes(2).TextFrame.TextRange.Text = rst.Fields("Name")

(Note: oSlide.Shapes(1) is the Title shape of the slide!)
It works fine.

The problem is I'cant figure out how to put a bitmap from a field in the
recordset which is OLEObject on the third shape of each slide. Actually
I'm looking for the property following:

oSlide.Shapes(3).<what comes here?> = rst.Fields("BitmapPicture")

Can anybody give some advice?

TIA,
Primoz
 
The problem is I'cant figure out how to put a bitmap from a field in the
recordset which is OLEObject on the third shape of each slide. Actually
I'm looking for the property following:

oSlide.Shapes(3).<what comes here?> = rst.Fields("BitmapPicture")

Can you copy the bitmap picture to the clipboard from Access?

If so:

Dim oSh as Shape
Set oSh = oSlide.Shapes.Paste(1)
' modify oSh properties as needed

If you need to apply a picture fill to an existing shape:

oSh.Fill.UserPicture sPathToPicture

You'd need to somehow export the picture from Access to a file first to do
this.


--
Steve Rindsberg, PPT MVP
PPT FAQ: www.pptfaq.com
PPTools: www.pptools.com
================================================
Featured Presenter, PowerPoint Live 2004
October 10-13, San Diego, CA www.PowerPointLive.com
================================================
 
Thanks Steve for your answer!

I've figured out myself that it's easier to work with bitmap pictures
separated from Access DB and having only paths kept in a field of a
table. I use

oSlide.Shapes.AddPicture FileName:=sPath, _
LinkToFile:=False, SaveWithDocument:=True,Left:=...

and it works fine.
But suppose I'd like to have bitmap pictures embedded in a table as
OLEfield.

I don't quite understand what you mean with
Dim oSh as Shape
Set oSh = oSlide.Shapes.Paste(1)

I'm certanly not going to copy pictures from a table field to a
clipboard manually and then put it on a slide with these statements.
Or I misunderstood you ?

What I want is to loop through all ADODB recordset-records and in each
turn insert bitmap picture from the record into a PPT shape on a slide.

Primoz
 
Glad the suggestions were a help.
But suppose I'd like to have bitmap pictures embedded in a table as
OLEfield.

I don't quite understand what you mean with


I'm certanly not going to copy pictures from a table field to a
clipboard manually and then put it on a slide with these statements.
Or I misunderstood you ?

No, not manually. I don't use Access so I'm not familiar with what it can do.
IF it can copy the bitmap images to the clipboard under program control, the
snipped above would paste the image back into PPT, giving you a reference to
the newly pasted shape in oSh, which you could then manipulate:

With oSh
.Height = this
.Width = that
.Etcetera = whatever
End With
What I want is to loop through all ADODB recordset-records and in each
turn insert bitmap picture from the record into a PPT shape on a slide.

Primoz

--
Steve Rindsberg, PPT MVP
PPT FAQ: www.pptfaq.com
PPTools: www.pptools.com
================================================
Featured Presenter, PowerPoint Live 2004
October 10-13, San Diego, CA www.PowerPointLive.com
================================================
 
Back
Top