Create Word document from Access Query - Import image based on pat

S

SB

Hi,

I need to create a Word document using data from an Access query. I can do
this successfully using a mail merge. One of the fields is the UNC path to an
image. I would like to insert the image into the document each time a new
record is read. For example

<<Field1>> <<Field2>> <<Field6 - Pathname>>
<<Field3>> <<Field4>>
<<Field5>>
---------------------------------------------------------------

Field6 - Pathname is replaced by the actual image. Can the image also be
resized?


I do this in access using

If IsNull(Me.Expr1) Or IsEmpty(Me.Expr1) Then
Me.Image30.Picture = "\\server\path\noimage.jpg"
Else
Image30.Picture = Me.Expr1
End If

Where Expr1 is the path.

Can I do similar in Word VBA? My end user requires the output in Word so
they can further format it before incorporating it into a book.

Have I confused everyone yet?

thanks

Scott
 
C

Cindy M -WordMVP-

Hi =?Utf-8?B?U0I=?=,

In the Mail Merge FAQ on my website you'll find the technique for merging a
picture into Word. It involves embedding the file path into an InsertPicture
field, so you're on the right track :)

The trickier part could be the resizing. Unfortunately, you don't go into any
detail about what you have in mind, here. But first try things out so that you
can see what, if anything, needs to be done.
I need to create a Word document using data from an Access query. I can do
this successfully using a mail merge. One of the fields is the UNC path to an
image. I would like to insert the image into the document each time a new
record is read. For example

<<Field1>> <<Field2>> <<Field6 - Pathname>>
<<Field3>> <<Field4>>
<<Field5>>
---------------------------------------------------------------

Field6 - Pathname is replaced by the actual image. Can the image also be
resized?


I do this in access using

If IsNull(Me.Expr1) Or IsEmpty(Me.Expr1) Then
Me.Image30.Picture = "\\server\path\noimage.jpg"
Else
Image30.Picture = Me.Expr1
End If

Where Expr1 is the path.

Can I do similar in Word VBA? My end user requires the output in Word so
they can further format it before incorporating it into a book.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail :)
 
S

SB

Thanks Cindy,

I have done a little more research and found the InlineShapes collection and
was looking at how to use that. I'll also have a look at the FAQ on your
website. As for resizing, in Access I put a placeholder for the image on a
report and set the Size Mode property to Zoom and the Picture Alignment
property to Center, this produces the image size that I need. Looking at the
AddPicture method of the InlineShapes collection I see that I can only
specify a fixed size, i.e. I can't zoom to a boundary - looks like more
experimenting.

Once again, thanks for your reply

Regards

Scott
 
C

Cindy M -WordMVP-

Hi =?Utf-8?B?U0I=?=,
I have done a little more research and found the InlineShapes collection and
was looking at how to use that. I'll also have a look at the FAQ on your
website. As for resizing, in Access I put a placeholder for the image on a
report and set the Size Mode property to Zoom and the Picture Alignment
property to Center, this produces the image size that I need. Looking at the
AddPicture method of the InlineShapes collection I see that I can only
specify a fixed size, i.e. I can't zoom to a boundary - looks like more
experimenting.
correct, Word does not have an exact equivalent. Some possibilities that come
to mind:

1. A Frame (Insert Frame is on the Forms toolbar) can limit the size of a
graphic, proportionally, to either the height or the width of the frame. But it
won't make a small image larger

2. There is an ActiveX control (Controls Toolbar) that should have a lot of the
characteristics of the Access control, you could look at that. ActiveX controls
can behave oddly in Word documents; I've never done much with this one. I'll be
interested in anything you have to report about it :)

3. If you use VBA to insert, then you can also resize. It doesn't have to be in
the code that inserts the image, you can work with the object after-the-fact.
Roughly:
Dim ils as Word.InlineShape
Set ils = doc.InlineShapes.Add('any params you want to use)
ils.Width = 1.1
ils.Height = 2.2

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail :)
 
S

SB

Thanks Cindy,

I need to automate as much of this as possible. There are around 6,000
images involved, that's why I considered the mail merge option. Initially I
used an access report dumped to a pdf and then converted to word but the
resulting document is difficult for the end user to edit, everything is in
frames - oh well, more experimenting required :)

Regards

Scott
 

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