How I can insert an image into a shape

A

Alexander Bartsev

How I can insert an image into a shape in Word document using VBA?
Thanks
 
J

Jay Freedman

Alexander Bartsev said:
How I can insert an image into a shape in Word document using VBA?
Thanks

To insert a picture into a shape, the picture *must* be an InlineShape
object -- otherwise, you have to insert two separate Shape objects,
overlap them, and possibly group them.

The code for the InlineShape goes something like this:

Dim oShp As Shape
Dim oImg As InlineShape

Set oShp = ActiveDocument.Shapes.AddShape( _
Type:=msoShapeOval, Left:=100, _
Top:=100, Width:=200, Height:=200)

With oShp.TextFrame.TextRange
Set oImg = .InlineShapes.AddPicture( _
FileName:="c:\clips\picture.gif")
End With
 

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