473,511 Members | 15,197 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Merging Access data and image files into Word

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


Nov 29 '06 #1
1 4735
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


Dec 2 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2055
by: Dan Nash | last post by:
Hi guys I wonder if you could help. I'm trying to create a bespoke interface for mail merging from an Access database in Word. At the moment, I'm just trying it with CSV files, and it works....
41
6056
by: Ruby Tuesday | last post by:
Hi, I was wondering if expert can give me some lite to convert my word table into access database. Note: within each cell of my word table(s), some has multi-line data in it. In addition, there...
5
4004
by: Jerry Hull | last post by:
I'm working with a database developed by an untrained person over several years - and on a network that has recently been upgraded with a new server installed and MS office upgraded from 2K (I...
1
4913
by: svdh | last post by:
I have posed a question last saturday and have advanced alot in the meantime. But I am still not there Problem is that I try to merging various fields from various tables in one document in Word...
3
4055
by: Bob Dydd | last post by:
Hi Everybody I have an Access 2000 db with a setup for inserting images in records. I am using the image path only with the actual images stored elswhere on the hard disc. This works perfectly...
1
3097
by: gm | last post by:
Hi; I have written a database that tracks all the installation we have ever done. I have a small heating company. I have recently started keeping a directory of digital photographs of the...
9
3815
by: Wayne Smith | last post by:
I've come up against a major headache that I can't seem to find a solution for but I'm sure there must be a workaround and I would really be grateful of any help. I'm currently building a web...
2
1561
by: timlitw | last post by:
A while back I researched and wrote a script that uses gd to make merge an arrow on a compass to show wind direction, and another on a speedometer to show wind speed, now I'd like to enhance these...
8
6684
by: babyangel43 | last post by:
Hello, I have a query set up in Access. I run it monthly, changing "date of test". I would like this query to be merged with a Word document so that the cover letter is created in Word, the fields...
0
7237
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7349
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7074
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7506
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5063
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3219
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3210
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1572
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
445
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.