View Single Post
  #18   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Doug Robbins - Word MVP Doug Robbins - Word MVP is offline
external usenet poster
 
Posts: 8,832
Default Merging pictures

Peter,

Using

{INCLUDETEXT {IF TRUE "C:\\Test_Files\\ThisFileDoesNotExist.JPG"} \c
Recover }

results in nothing being displayed in 2007, but using

{INCLUDETEXT {IF TRUE "C:\\Test_Files\\ThisFileDoesExist.JPG"} \c Recover }

sort of predictably results in the following error message:

"There are too many spelling or grammatical errors in Document1 to continue
displaying them. To check the spelling and grammar of this document, choose
Spelling and Grammar from the Review tab."

without the \c recover, I get the File Conversion dialog box in which I get
the opportunity to select the encoding that makes your document readable.

It's a pity word does not have an { IF ERROR } field.
--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
"Peter Jamieson" wrote in message
...
With one or two provisos, how about the following for Word 2007?

{IF{INCLUDETEXT {IF TRUE "O:\\Pictures\\2009 Original Church
Pictures\\{MERGEFIELD Full_Name}"} \c Recover }= "Error! Not a valid
filename." "" {INCLUDEPICTURE {IF TRUE
"O:\\Pictures\\2009 Original Church Pictures\\{MERGEFIELD Full_Name}"}}}

Proviso 1 is that when the file does not exist, merge flags an error that
you cannot suppress AFAICS by setting .displayalerts to wdAlertsNone - you
have to select the third option in Auto Check for Errors.

Proviso 2 is...well, it's untested. I have been down a similar route
before, and if Word is forced to open large JPGs, it can be a very slow
process. I have a feeling that there was another problem, but that might
be the one that you have solved with your nifty { INCLUDEstuff { IF TRUE
pathname } } construction.

I don't know why Word 2007 comes up with an "Error! Not a valid filename."
error in this case. The pathname looks OK to me, unless Word doesn't like
the double backslashes in this case. Word 2000 at least seems to return
the expected "Error! Cannot open file."

BTW when I use either this

{IF{INCLUDEPICTURE {IF TRUE "O:\\Pictures\\2009 Original Church
Pictures\\{MERGEFIELD Full_Name}"}}= "" "" {INCLUDEPICTURE {IF TRUE
"O:\\Pictures\\2009 Original Church Pictures\\{MERGEFIELD Full_Name}"}}}

or this

{IF{INCLUDEPICTURE {IF TRUE "O:\\Pictures\\2009 Original Church
Pictures\\{MERGEFIELD Full_Name}"}} "" {INCLUDEPICTURE {IF TRUE
"O:\\Pictures\\2009 Original Church Pictures\\{MERGEFIELD Full_Name}"}}}

in either 2007 or 2000 it always leaves /a/ picture in the output document
when the file is missing. In 2007 it's the same as the previous
successfully inserted picture as discussed, but in 2000 it's a square
blank picture or perhaps a placeholder. If you're finding that nothing is
inserted in pre-2007 Word when the file is missing I wonder why there's a
behaviour difference? When the file is present, the construction works
exactly as you say.


Peter Jamieson

http://tips.pjmsn.me.uk

macropod wrote:
Hi colblip,

If, as I am now beginning to suspect, you don't have a field in your data
for the image names and you're simply relying on a field that contains
the peoples' names (ie 'Full_Name'), then a field-based solution isn't
possible with Word 2007. For previous versions you could use:
{IF{INCLUDEPICTURE {IF TRUE "O:\\Pictures\\2009 Original Church
Pictures\\{MERGEFIELD Full_Name}"}}= "" "" {INCLUDEPICTURE {IF TRUE
"O:\\Pictures\\2009 Original Church Pictures\\{MERGEFIELD Full_Name}"}}}