Set Format Picture | Layout using VBA

T

TimTDP

I use the following code to insert a picture into Word 2000 from Access 2000:
Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim oShp As InlineShape
Dim shp As Shape

Set db = CurrentDb()
Set rst = db.OpenRecordset("select * from tblData")

Dim objWord As Word.Application

' Launch Word and load the invoice template
Set objWord = New Word.Application
objWord.Documents.Add "C:\CoverPage.dot"
objWord.Visible = True

' Add header information using predefined bookmarks
With objWord.ActiveDocument.Bookmarks
.Item("PreparedFor").Range.Text = rst!PreparedFor
.Item("PreparedForAddress").Range.Text = rst!PreparedForAddress
Set oShp =
..Item("GraphicFile").Range.InlineShapes.AddPicture("C:\210.jpg", False, True)
End With

With oShp
.Fill.Visible = msoFalse
.Fill.Transparency = 0#
.Line.Weight = 0.75
.Line.DashStyle = msoLineSolid
.Line.Style = msoLineSingle
.Line.Transparency = 0#
.Line.Visible = msoFalse
.LockAspectRatio = msoFalse
.Height = 291.1
.Width = 387.5
.PictureFormat.Brightness = 0.5
.PictureFormat.Contrast = 0.5
.PictureFormat.ColorType = msoPictureAutomatic
.PictureFormat.CropLeft = 0#
.PictureFormat.CropRight = 0#
.PictureFormat.CropTop = 0#
.PictureFormat.CropBottom = 0#

Set shp = .ConvertToShape

With shp
.ZOrder msoSendBehindText
.WrapFormat.Type = wdWrapTight
End With
End With

Set oShp = Nothing
Set shp = Nothing

The above code inserts the picture and re-sizes it. However I am having
problems with formating the picture. I need to set the following:
Format Picture | Layout
Wrapping Style = Infront of text
Horizontal Position = Center

I have tried to set this suing the code below Set shp = .ConvertToShape but
with no luck.

What is the correct syntax?
 
J

Jezebel

No need to create an inline shape and convert it. Easier just to add the
shape itself ---

With objWord.ActiveDocument
With Shapes.AddPicture(Anchor:=.Bookmarks("GraphicFile").Range, _
FileName:="C:\210.jpg", _
LinkToFile:=False)

.WrapFormat.Type = wdWrapTight
.Left = wdShapeCenter
.ZOrder msoSendBehindText
end with
End With
 
T

TimTDP

What do I dimension Shapes as?

Jezebel said:
No need to create an inline shape and convert it. Easier just to add the
shape itself ---

With objWord.ActiveDocument
With Shapes.AddPicture(Anchor:=.Bookmarks("GraphicFile").Range, _
FileName:="C:\210.jpg", _
LinkToFile:=False)

.WrapFormat.Type = wdWrapTight
.Left = wdShapeCenter
.ZOrder msoSendBehindText
end with
End With
 
J

Jezebel

Sorry, that should be .Shapes

If you wanted to dimension an object (which you don'tr need to with that
syntax), --

Dim pShapes as Word.Shapes
 

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