Hello Paul,
Incase you dont have the answer yet, here is my attempt at it.
This following code is written for ADO on Access2000
Copy the code into a new module in your Access database.
It is the complete code based on your table name and fields.
It works as i have tried it, but it may not be the fastest way to do it, as
its fairly slow. Some wise guy will probably rip my code to pieces, but
someone always knows better.
This was a nice little challenge but its not mail merge its late binding
automation code so no reference library to word is needed so its not version
dependent.
Hope it helps.....you need to change the variable PathToFiles=?????
===================================
Function fntMakeCat()
Dim cnn As ADODB.Connection
Dim rst As New ADODB.Recordset
Dim wd As Object
Dim wdDoc As Object
Dim DocTable As Object
Dim tRange As Object
Dim irec As Integer
Dim PathToFiles As String
Dim tSelection As Object
Set cnn = CurrentProject.Connection
rst.ActiveConnection = cnn
PathToFiles = "C:\WordPicTest\" 'this is where your images are stored
rst.Open "tblProducts", cnn, adOpenKeyset
rst.MoveFirst
rst.MoveLast
Set wd = CreateObject("Word.Application")
wd.Visible = True
Set wdDoc = wd.Documents.Add
Set tSelection = wd.Selection
Set DocTable = wdDoc.Tables.Add(tSelection.Range, rst.RecordCount + 1, 4)
rst.MoveFirst
'set up the Header in the Table
Set tRange = DocTable.Cell(1, 1).Range
tRange = "Product"
Set tRange = DocTable.Cell(1, 2).Range
tRange = "Price"
Set tRange = DocTable.Cell(1, 3).Range
tRange = "Description"
Set tRange = DocTable.Cell(1, 4).Range
tRange = "Picture"
'populate the table with data
irec = 1
Do Until rst.EOF
irec = irec + 1
Set tRange = DocTable.Cell(irec, 1).Range
tRange = rst.Fields(0)
Set tRange = DocTable.Cell(irec, 2).Range
tRange = rst.Fields(1)
Set tRange = DocTable.Cell(irec, 3).Range
tRange = rst.Fields(2)
Set tRange = DocTable.Cell(irec, 4).Range
tRange.Select
tSelection.InlineShapes.AddPicture (PathToFiles & rst.Fields(0) &
".jpg") 'heres the magic bit
rst.MoveNext
Loop
rst.Close
cnn.Close
End Function
===================================
p.s Im liking the sound of those pink widgets !
"Paul H" <pa**@nospam.comwrote in message
news:7K******************************@eclipse.net. uk...
>I have a very simple database containing one table called "tblProducts".
The
fields are: ProductID, Description, Price.
I have a folder on my PC that contains image files. The image file names
are based on the associated ProductID, i.e. 2001.jpg is a picture of
ProductID 2001.
I know how automate Word mailmerge using VBA in access, but I want to
include the related pictures in the merged document. So the word doc will
have a table in it looking a bit like this:
Image ProductID Desc. Price
2001.jpg 2001 Blue Widget £10.00
2005.jpg 2005 Red Widget £11.00
2017.jpg 2017 Pink Widget £12.00
Obviously I need the image displayed rather than the image file name.
How can I do this. I can probably figure the code out myself, I just want
to know the approach or method to achieve this.
Thanks,
Paul