Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
![]()
Hi --
I want to pull an image from an image file (.jpg) into my document (table cell) if the image file exists, otherwise I want to leave the table cell blank. I've searched this group, and there doesn't seem to be any way to do this with just mail merge functions. I can of course preprocess my data source and file directory with VBA, output a processed file with fields indicating the image file to pull in (or not), and then use that processed file as my data source, but I'm trying to do this directly in mail merge. Any help or pointers would be appreciated. -- Roy Zider Word 2003, Windows XP SP2 |
#2
![]()
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
![]()
I don't think there is a way to do this using fields, at least not without
writing your own text converter, which I cannot recommend. To do it, you would have to construct a field that returns a testably different result depending on whether or not the file exists, e.g. { INCLUDEPICTURE "{ IF "{ SOMEFIELDTYPE "picturepath" }" = "Error! File not found" "blankpicturepath" "picturepath" }" } I don't think you can successfully use INCLUDEPICTURE as the SOMEFIELDTYPE. In theory you might be able to use { INCLUDEPICTURE "{ IF "{ INCLUDETEXT "picturepath" \c Recover }" = "" "blankpicturepath" "picturepath" }" } but in practice Word seems to get very confused if you attempt this (it takes quite a long time to read large image files, for one thing), and does not reliably evaluate INCLUDETEXT in the way you might hope. Possibly worth trying for your own satisfaction. Another approach might be to use a DATABASE field to invoke some SQL that tests for file existence. However, I don't think you can do this using Jet SQL because none of the functions you might use for that (dir, filelen, etc.) are available. Other ways you can potentially avoid preprocessing (other than postprocessing!): a. the official way, using Word's MailMerge events, e.g. in VBA b. if your data source happens to be an Access .mdb and you can connect using DDE, write an Access VBA function that tests for file existence and returns either a flag or perhaps the name of a blank file. Then call that function in an Access query and use that query as your data source. (NB, as far as I know, you can't combine this approach with the DATABASE approach because the DATABASE field cannot get data from an Access query via DDE any more). Peter Jamieson "FUBARinSFO" wrote in message oups.com... Hi -- I want to pull an image from an image file (.jpg) into my document (table cell) if the image file exists, otherwise I want to leave the table cell blank. I've searched this group, and there doesn't seem to be any way to do this with just mail merge functions. I can of course preprocess my data source and file directory with VBA, output a processed file with fields indicating the image file to pull in (or not), and then use that processed file as my data source, but I'm trying to do this directly in mail merge. Any help or pointers would be appreciated. -- Roy Zider Word 2003, Windows XP SP2 |
#3
![]()
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
![]()
Peter:
I was afraid of that. I had read your earlier posts and comments about the use of INCLUDETEXT. Reading hundreds of jpg files to force an error message wasn't in the cards. In addition, it seems Microsoft has dropped the error message from the use if INCLUDEPICTURE |
#4
![]()
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
![]()
Peter:
I was afraid of that. I had already read your earlier comments about INCLUDETEXT, and no way was I going to search through hundreds of jpg files as a way to force an error message. Microsoft Word used to emit an error message (along the lines you mention here) when INCLUDEPICTURE did not find the requested file, but evidently it now goes silently into the night. I will simply preprocess the data source and feed that preprocessed source into the mail merge document, and be done with it. Thank you so much for your prompt and comprehensive reply. -- Roy Zider |
Reply |
Thread Tools | |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
I **want** Word to ask me to save if file already exists! | Microsoft Word Help | |||
MS '03 Offc. Issue - Normal file already exists message upon exit | Microsoft Word Help | |||
The file normal.dot already exists | New Users | |||
Toolbar exists, but unavailable | Microsoft Word Help | |||
Normal File already exists? | New Users |