>I'm trying to use an OLE link to Word to paste 3 bitmaps and print them on a single page. Code:
>
>oleApp = createobject("word.application")
>with oleApp
> .visible = .T.
> .Documents.Add
>
>* paste, and position first bitmap
> .Selection.Paste
> .ActiveDocument.Shapes("Picture 2").Select
> .Selection.ShapeRange.RelativeHorizontalPosition = 1
> .Selection.ShapeRange.RelativeVerticalPosition = 1
> .Selection.ShapeRange.Left = 100
> .Selection.ShapeRange.Top = 115
> ...
>
>Problem:
>Word assignes this pasted image a tag like "Picture 2". I need to reference this newly pasted image to position it properly. The tag is incremented with each picture, but doesn't start at 1.
>
>Is there a way to set this tag or at least find out what the tag is so I can reference the picture?
>
>Thanks.
You're even lucky it's named "Picture" :) You could use shapes collection object if there are no other shapes before you paste. You paste 3 of them and then refer to them like oleApp.Activedocument.shapes(1), shapes(2), shapes(3). But another long way seem to be safer. Get selection start position before paste and selection end position after paste. In that range shaperange(1) is the newly pasted one. ie:
oWord = createobject("word.application")
WITH oWord
.Documents.Add
lnStart = .Application.Selection.Start
.Application.Selection.Paste
lnEnd = .Application.Selection.End
oShape1 = .ActiveDocument.Range(lnStart, lnEnd).ShapeRange(1)
lnStart = .Application.Selection.Start
.Application.Selection.Paste
lnEnd = .Application.Selection.End
oShape2 = .ActiveDocument.Range(lnStart, lnEnd).ShapeRange(1)
lnStart = .Application.Selection.Start
.Application.Selection.Paste
lnEnd = .Application.Selection.End
oShape3 = .ActiveDocument.Range(lnStart, lnEnd).ShapeRange(1)
WITH oShape1
.RelativeHorizontalPosition = 1
.RelativeVerticalPosition = 1
.Left = 100
.Top = 115
lnNextTop = .Top + .Height
ENDWITH
WITH oShape2
.RelativeHorizontalPosition = 1
.RelativeVerticalPosition = 1
.Left = 200
.Top = lnNextTop + 15
lnNextTop = .Top + .Height
#DEFINE msoPictureWatermark 4
.PictureFormat.Colortype = msoPictureWatermark
ENDWITH
WITH oShape3
.RelativeHorizontalPosition = 1
.RelativeVerticalPosition = 1
.Left = 150
.Top = lnNextTop + 30
ENDWITH
.visible = .t.
ENDWITH
Cetin