Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Merging Images 1

Status
Not open for further replies.

Scott24x7

Programmer
Jul 12, 2001
2,827
JP
All,
I have a word document that I'm merging data from an excel spread sheet into the word document. I now have a photo that is associated with the Excel rows. So my date is like this in excel:

Code:
Name          Department          Photo
Bob Smith     Accounting          \Photos\bobsmith.jpg
Mary Jane     Sales               \Photos\maryjane.jpg
Tom Jones     Sales               \Photos\tomjones.jpg
...

So on my word doc, I'm merging fields <F1> <F2> I want to be able to "merge" field <F3> in but as the actual photo in the column (and the path is correct).

Is this possible? Or is there some other step I need that will make this possible?

Thanks!

Best Regards,
Scott

"Everything should be made as simple as possible, and no simpler."[hammer]
 
Hi Scott,

To merge the pictures you'll need to incorporate your Photo field into an INCLUDEPICTURE field. The following field code construction will both do that and unlink the pictures from the source files (which a simple INCLUDEPICTURE field won't do):

{IF {INCLUDEPICTURE {IF TRUE «Photo»} \d} {INCLUDEPICTURE {IF TRUE «Photo»} \d}}

or

{IF {INCLUDEPICTURE {IF TRUE {MERGEFIELD Photo}} \d} {INCLUDEPICTURE {IF TRUE {MERGEFIELD Photo}} \d}}

Note: The field brace pairs (ie '{ }') for the above example are created via Ctrl-F9 - you can't simply type them or copy & paste them from this message. Likewise, you can't type or copy & paste the chevrons (ie '« »') - they're part of the actual mergefields, which you can insert from the mailmerge toolbar.



Cheers
[MS MVP - Word]
 
Macropod,
Just for clarity, this is in the Word Document, or the Excel field?
Looks like you mean Word... so I'll give that a try first. :)


Best Regards,
Scott

"Everything should be made as simple as possible, and no simpler."[hammer]
 
Hi Scott,

Yes, it's all in Word.


Cheers
[MS MVP - Word]
 
Macropod,
Must be doing something wrong. I've tried both of the examples above, and either get a "broken" image box, or blank. And what is somewhat vexing as well, if I do a "preview" in the Mailings ribbon, when I exit the preview, my merge string (as above) is gone. (Though it shows the other fields...)
Any suggestions?


Best Regards,
Scott

"Everything should be made as simple as possible, and no simpler."[hammer]
 
Hi Scott,

I notice that your 'Photo' field lacks the drive designation. You need that, plus whatever other parts of the path are missing. You could hard-code that info into the mergefield, or use some fancy coding to generate a relative path - useful mainly if the filepath is laible to change.

For hard-coding the path, use something along the lines of:
{IF {INCLUDEPICTURE {IF TRUE "C:\My Documents«Photo»"} \d} {INCLUDEPICTURE {IF TRUE "C:\My Documents«Photo»"} \d}}

For a relative path, use something along the lines of:
{IF{INCLUDEPICTURE {IF TRUE "{FILENAME \p}\..\«Photo»"} \d} {INCLUDEPICTURE {IF TRUE "{FILENAME \p}\..\«Photo»"} \d}}




Cheers
[MS MVP - Word]
 
Macropod,
I had a feeling it might be related to that, so did some experimenting and found one that worked. (Strangely, I had given the example above as "what I might do", and I had the fully qualified path in my real data source, but it didn't work. When I stripped it down to a child DIR in the same location as the Word doc, it worked! (Though to be honest, I'm not sure which of the two examples above it did work on, but it asks me which "field" to pick to populate it with (twice) so I assume it's from the "IF TRUE" part. I think it came from the second one.
In any case, thanks. This is a big time saver.
Cheers!

Best Regards,
Scott

"Everything should be made as simple as possible, and no simpler."[hammer]
 
Wow... this process is SO frustrating!
I tried now to replicate it in a new word doc, and I can't repeat it! If I use option 1, when I pick the field, in the middle of that merge string, the whole string vanishes as soon as I place it. (The one in chevrons). Then I get nothing. Option two gives me blank line when I preview, and when I come back, it is gone too! What am I doing wrong?

Best Regards,
Scott

"Everything should be made as simple as possible, and no simpler."[hammer]
 
Hi Scott,

Without seeing your document, I'd only be guessing. I've tested the field coding I gave you, so I know it works. Make sure you've got all the nesting & spacing right. Pressing Alt-F9 toggles the field code display on/off.


Cheers
[MS MVP - Word]
 
Macropod,
Ok, I'm replicating it now. Must have been in the spacing, and I use option 2, which prompts me for which field to use as the picture field from my data source each time, but that is no problem at all. Thanks for the tips!

Best Regards,
Scott

"Everything should be made as simple as possible, and no simpler."[hammer]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top