Help to merge Image (Doug Robins?)

J

JohnB

Hi.

Im trying to mail merge an Image, whose path is stored in an Access 2002 mdb
field and Ive seen a previous post mentioning MVP Cindy Meister's website.
Ive also had a look at Word Help on Include Picture. But I cant get it to
work.

The main problem seems to be that I am unable to get the actual merge code
to appear so that I can edit it. Cindy suggests the following:

Reference the graphic file information by nesting the merge field in an
IncludePicture field.
Example: { IncludePicture "C:\\Data\\Pics\\{ Mergefield Signature \*
upper }" }

How do I get her example code to appear in the document so that can edit it?
Ive tried cutting and pasting her code but that doesnt work. Ive tried using
Insert\Ptcture\FromFile with Link To File checked but this only gets an
image to appear - I cant see the code to edit it so that I can include the
path.

What am I doing wrong?

Thanks for any help, JohnB
 
P

Peter Jamieson

You have to use ctrl-F9 to insert the special filed code braces - { } - used
in Word. All the rest of the text can be typed or pasted in the usual way.

e.g. in a Word document, press ctrl-F9.
You see { }.
Type INCLUDEPICTURE "C:\\Data\\Pics\\" inside the { }
You see { INCLUDEPICTURE "C:\\Data\\Pics\\" }
Putt he insertion point before the last " and press ctrl-F9.
You see { INCLUDEPICTURE "C:\\Data\\Pics\\{ }" }
Type Mergefield Signature \*upper inside the new { }
You see { INCLUDEPICTURE "C:\\Data\\Pics\\{ Mergefield Signature
\*upper }" }

Peter Jamieson
 
J

JohnB

Hi Peter.

Sorry but this does not work for me. Im using Access 97 and Word 97 if that
matters. I tried this in an existing merge document, then in a brand new
Word document that I merged with a data source.

Before inserting any merge fields from the source, I tried Alt F9 - nothing
appeared. I then inserted one merge field. Using F9 alternately changes the
merge field from <<FamilyName>> to {FamilyName} but I cant get { } to
appear on their own.

Any further ideas?

Thanks for the help, JohnB
 
A

Anne Troy

Once you are viewing the merge field codes (using Alt+F9, then--with your
cursor inside that mergefield code, you can hit Ctrl+F9 to add another set
of brackets.

If Alt+F9 doesn't show you the field codes, please follow the instructions
at the link I gave you, which states: Hit Alt+F9 or go to ToolsàOptionsàView
tab and turn on viewing of Field Codes.

Once you are viewing these, Ctrl+F9 should do something in your document. It
seems to me that you're simply not viewing them. A merge field will show,
whether Alt+F9 is chosen or not. A Ctrl+F9 is "nothing" unless you're
viewing field codes.

*******************
~Anne Troy

www.OfficeArticles.com
www.MyExpertsOnline.com
 
J

JohnB

Hi again Anne.

I wonder if you read my reply to Peter before you posted this. Ive done as
you said and selected Tools\Options\View and clicked to show field codes.
However, you say ".......you can hit Ctrl+F9 to add another set of
brackets." This does not happen. Pressing F9 just toggles between fields
showing as, say, <<FamilyName>> and {MERGEFIELD FamilyName}. I cant get just
{ } to appear on their own. Perhaps I should wait and try this at work -
there Im using Access and Word 2002 on XP, so maybe it will work.

Thanks again for the help. JohnB
 
P

Peter Jamieson

Let's just make sure we're talking aboutt he same things here:
Alt-F9 switches between field "codes" view (where you should see e.g. {
MERGEFIELD FamilyName }) and Field "results" view (where you see the data or
<<FamilyName>> depending on whether you clicked the <<abc>> button in the
merge toolbar.
F9 normally just re-executes any selected fields
ctrl-F9 inserts a blank field, i.e. { }

The same key combinations were used in Word 97.

It's possible that some of these key combinations have been reassigned on
your copy of Word.ctrl-F9 - you should be able to check using
Tools|Customize|keyboard, select All Commands in the left-hand column, then
select InsertFieldCodes in the other list. See if ctrl-F9 is shown as the
shortcut combination.If it isn't, it could be for a good reason (e.g. some
addin you use all the time may use it), so I would check before assigning
ctrl-F9 to this function again. As a workaround, you can go back to the
opening pane of the Tools|Customize dialog, select Commands, select category
All Commands, find InsertFieldCodes and drag it to a toolbar or menu.

If ctrl-F9 hasn't been re-assigned, not sure what is going wrong but another
workaround would be to cut/paste an existing field and change the contents.

Peter Jamieson
 
J

JohnB

Arrrrrrg. So sorry Peter (and Anne).

I feel a real chump. I thought you meant Alt F9, when you clearly said Ctrl
F9. Now I see that this works and puts { }, ready for me to insert my text
stuff.

Sadly Ill have to leave it there for now but please keep an eye on this
thread. Ill definately get back to you with progress tomorrow am (GMT).

Thanks for sticking with me on this one. Cheers, JohnB
 
J

JohnB

Hi Peter and Anne.

A big big apology - yes youre right, I read Alt F9 when you clearly said
Ctrl F9. I can now get the { } symbols. Ill have to leave it there for the
moment. Please keep an eye on this thread and Ill let you know how I get on.
(Im not quite sure what Cyndy means by Mergefield Signature in her code. Is
Signature the name of the field holding the path to the image? So, if my
fieldname is Image, I put Mailmerge Image in the code?


Thanks for all the help, JohnB
 
P

Peter Jamieson

Yes.

Peter Jamieson

JohnB said:
Hi Peter and Anne.

A big big apology - yes youre right, I read Alt F9 when you clearly said
Ctrl F9. I can now get the { } symbols. Ill have to leave it there for the
moment. Please keep an eye on this thread and Ill let you know how I get
on.
(Im not quite sure what Cyndy means by Mergefield Signature in her code.
Is
Signature the name of the field holding the path to the image? So, if my
fieldname is Image, I put Mailmerge Image in the code?


Thanks for all the help, JohnB
 
J

JohnB

Hi again.

Sorry for the delay. Our network was down at work today so I couldnt try
this out until I got home. Im still playing around with it but I need more
time. Ill post again tomorow.

Cheers, JohnB
 
J

JohnB

Hi Again.

Ive now had a chance to try out this feature using Access 2002 on XP,
networked, here at work. Ill give a full description of what Im trying to do
and what is happening but I feel that I now need to ask exactly what the
field code should look like for my particular case. Word changes the merge
field code I enter, whenever I save.

Heres the set up. I have a sample Access 2002 database, with a query
containg three fields, StudentID, StudentName and ImagePathAndFile. I have
three records in the table feeding this query, containg the following. The
query selects all three records.

1 Fred First U:\Personal\MVC-002S.JPG
2 Jim Second H:\Images\MVC-003S.JPG
3 Ed Third U:\Personal\BlackAndWhite.JPG

Next, I open a blank Word document and merge it to the query. I insert the
field StudentName and can see it on the main and merged documents. Next I put
in the code to add the pictures.

I 'think' that the following is what I should enter as the complete field
code, but its behaving oddly.

{ IncludePicture " {MERGEFIELD "ImagePathAndFile" \ * upper } " }

I put this in, then highlight it and use Update Field, then I can
successfully use Alt F9 to toggle the field code on and off. With it off, I
can see a picture but its the same picture on all three records in the Main
document. If I go to record two, highlight the picture and choose Update
Field, then the picture changes to that records picture and that same picture
is now shown for all three records. When I merge to a new document, whichever
picture was selected at the Update Field stage, is shown on all three merged
pages. I.e. individual records pictures are not being shown. If I use Ctrl A
and Update Field, nothing changes. Now for the interesting bit. I close the
merged document and save the main document, then reopen it. Now the field
code shows as:

{INCLUDEPICTURE "MVG-002S.JPG%20" \ * MERGEFORMATINET"}

When I use Alt F9, the same picture shows in each record but when I
highlight it and use Update Field, it doesnt change. Also, when I merge to a
new document, the same picture shows on all pages.

OK Im probably doing something very stupid, so please put me out of my
misery. Is my picture merge field code even remotely correct? If not, what
should it be and why is Word changing the code when I save?

Many thanks for any help you can give. Cheers, JohnB
 
P

Peter Jamieson

Unfortunately there's yet another thing to do in this case - go into Word
Tools|options|General|Web Options|Files and uncheck "Update links on save".
Although in my opinion this setting should not affect documents that you are
saving as .doc, not .htm(l), it does.

Peter Jamieson
 
J

JohnB

Thanks Peter.

I read this after I left work, so Ill have to wait to try this tomorrow.
Curious - I already have a database with a large number of mail merges built
in and I havent had to modify any settings in Word up to now. Ill get back
to you tomorrow.

Cheers, JohnB
 
J

JohnB

Hi Peter.
Ive looked at that and the box is already checked. Where do I go from here?
Is my merge code correct? (I think not). Why is it being converted on save?
Unless I can get an answer to these questions I think Im at a dead end.

Thanks, JohnB
 
J

JohnB

Thanks Peter and yet again, sorry.

OK. Done that and played around further. Ive now got it to work, sort of.
Ive discovered that this only works if the path stored in field
ImagePathAndFile contains double \ characters between path folders, like this:

U:\\Personal\\MVC-002S.JPG

It will not show individual pictures for each record if just single \
symbols are used - it shows the first picture for all records. Is there a way
of adjusting the merge field code to cater for paths with only single \ ?

Just to repeat, Im using the following:

{ IncludePicture " {MERGEFIELD ImagePathAndFile \ * upper } " }

Thanks again for sticking with me on this. JohnB
 
P

Peter Jamieson

You are right about the doubling up of backslashes, and you may also need to
know that if you are using a UNC pathname where you would have
\\computername\sharename\filename.ext, you would need four backslashes
before the computername.
of adjusting the merge field code to cater for paths with only single \ ?

Not as far as I know. The only ways I know how to do it are to fix your
data source in one way or another, to use the Word Mail Merge Events in Word
2002/2003 to process the pathnames and insert them using, say, a DOCPROPERTY
field, or fix the pathnames after the merge, perhaps also using VBA.

In the case of an Access DB fixing the pathnames would typically mean:
a. you change the way the paths are stored in the first place, which may of
course have many knock-on effects on other applications, and it may not be
possible if you are not maintaining the data
b. you add a field to the appropriate table(s) and maintain a
double-backslashed version of the same data, perhaps adding a step before
the merge to fix all the data. or maybe you create a new table to do that
c. you try to create a formula in a query that doubles up the backslashes
for you "on-the-fly", and use that query as the data source for your merge.
Unfortunately, to do that, you either have to
- consider using the replace function in the query. Off the top of my head
ISTR that that particular function requires that you know how many replaces
you might need to do.
- use an Access VBA function. But that will require that you connect to
your Access database using DDE.

So no points for whoever didn't just make it very easy to insert pictures
from a merge in the first place...

Peter Jamieson
 
B

Bob K

Hi folks
I have been following your discussion intensely since yesterday afternoon to
22/6/05 when I started to do the same exercise. I think you’ve already
cracked it. The coding I’m using is and that is using just a straight
reference code in the worksheet all the extensions are in the merge field.
What you have to do is merge to a new document or your pages press Ctrl+A to
select all the fields and then press F9 to update all the fields you will now
find that your pictures are in the right place. I’m working with office word
2003 and Excel I am assuming this is going to work with the earlier versions
that you’re working with. This is fine if you’ve got a picture for each page
otherwise it appears to default to the picture that was there before the mail
merge. My thought to get around this is possibly set up the mail merge with a
dummy image saying no PICTURE AVAILABLE unless anybody has a better
suggestion.
I thank you all for your help it has been very interesting and I’ll keep
watching this space.
 
B

Bob K

Sorry I didn't see the coding didn't paste.
{ INCLUDEPICTURE c:\\cbs\\pubpics\\{ MERGEFIELD “PicRef†\* upper }.jpg}
by the way what dose the [ \ * upper ] refer to?
 

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