Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.mailmerge.fields
FUBARinSFO FUBARinSFO is offline
external usenet poster
 
Posts: 6
Default Check if file exists

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   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Peter Jamieson Peter Jamieson is offline
external usenet poster
 
Posts: 4,582
Default Check if file exists

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   Report Post  
Posted to microsoft.public.word.mailmerge.fields
FUBARinSFO FUBARinSFO is offline
external usenet poster
 
Posts: 6
Default Check if file exists

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   Report Post  
Posted to microsoft.public.word.mailmerge.fields
FUBARinSFO FUBARinSFO is offline
external usenet poster
 
Posts: 6
Default Check if file exists

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

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
I **want** Word to ask me to save if file already exists! Mark A. Snyder Microsoft Word Help 4 November 27th 06 12:15 AM
MS '03 Offc. Issue - Normal file already exists message upon exit airam_ytnom Microsoft Word Help 1 April 8th 06 12:24 AM
The file normal.dot already exists Ron Boetger New Users 1 February 24th 06 10:20 AM
Toolbar exists, but unavailable Sarah Jane Microsoft Word Help 6 December 12th 05 06:25 PM
Normal File already exists? Tieu New Users 4 December 28th 04 02:30 PM


All times are GMT +1. The time now is 11:35 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"