From: Mojo on
Hi All

My VB6 app inserts mutliple pictures into a Word doc template, but because I
don't know whether it will be 1 image (with accompanying text) or 36 images
(ditto) my idea was to just have a pre-created table of 1 row and 1 col and
then just keep inserting the pic then text in a long vertical list, eg:

Pic
title of pic
comment

Pic
title of pic
comment

Pic
title of pic
comment

etc

I've used the following code up to now:

Set oPic = oNewDoc.Tables(1).Cell(1, 1).Range.InlineShapes.AddPicture _
(MyPics & "\DCP_1960.JPG", False, True)

oPic.Width = 200
oPic.Height = 150
oNewDoc.Tables(1).Cell(1, 1).Range.Text = oNewDoc.Tables(2).Cell(2,
2).Range.Text & _
vbCrLf & "Jenny in Brid" & vbCrLf & "comments here"

But as you will probably know already, I can't add another pic to the above
code. If I do set oPic again then it overwrites the above pic and text.

Is there anyway I can concat a number of pics and text to drop into 1 cell
or have I got to have 1 cell for each pic??

Thanks


From: Doug Robbins - Word MVP on
Use a construction such as:

Dim otable As Table
Dim orow As Row
Dim ocell As Cell
Dim i As Long
Set otable = ActiveDocument.Tables(1)
'Set up a loop that iterates through all of the pictures
For i = 1 To [pictures].Count
If i = 1 Then
Set ocell = otable.Cell(1, 0)
Else
Set orow = otable.Rows.Add
Set ocell = orow.Cells(1)
End If
Set oPic = ocell.Range.InlineShapes.AddPicture _
(MyPics & "\DCP_1960.JPG", False, True)
oPic.Width = 200
oPic.Height = 150
Next i


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com

"Mojo" <please(a)dont.spam.com> wrote in message
news:#4qu23pzKHA.6112(a)TK2MSFTNGP05.phx.gbl...
> Hi All
>
> My VB6 app inserts mutliple pictures into a Word doc template, but because
> I
> don't know whether it will be 1 image (with accompanying text) or 36
> images
> (ditto) my idea was to just have a pre-created table of 1 row and 1 col
> and
> then just keep inserting the pic then text in a long vertical list, eg:
>
> Pic
> title of pic
> comment
>
> Pic
> title of pic
> comment
>
> Pic
> title of pic
> comment
>
> etc
>
> I've used the following code up to now:
>
> Set oPic = oNewDoc.Tables(1).Cell(1, 1).Range.InlineShapes.AddPicture _
> (MyPics & "\DCP_1960.JPG", False, True)
>
> oPic.Width = 200
> oPic.Height = 150
> oNewDoc.Tables(1).Cell(1, 1).Range.Text = oNewDoc.Tables(2).Cell(2,
> 2).Range.Text & _
> vbCrLf & "Jenny in Brid" & vbCrLf & "comments here"
>
> But as you will probably know already, I can't add another pic to the
> above
> code. If I do set oPic again then it overwrites the above pic and text.
>
> Is there anyway I can concat a number of pics and text to drop into 1 cell
> or have I got to have 1 cell for each pic??
>
> Thanks
>
>