Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 08-02-2016, 10:21 AM
utzja1 utzja1 is offline MERGE with IF field Windows 7 64bit MERGE with IF field Office 2013
Novice
MERGE with IF field
 
Join Date: Jun 2015
Posts: 11
utzja1 is on a distinguished road
Default MERGE with IF field

HI All,



I am trying to trying to use the mail merge utility to generate some inspection reports. Some of the inspection reports will have photos of defects (stored in PhotoPath1), but not all will have them. So I am attempting to use the IF field to check if the Photo Path is a blank (<> ""), and then to paste the picture at the path if there is a path to a defect photo. I can get the photo title to show up only when the Photo Path is not blank, but I am not getting the picture to come in also. I couldn't get the field text to paste in here so I have re-typed it. This is just as it appears in the WORD document.

{ IF {{MERGEFIELD PhotoPath1} <> "" {INCLUDEPICTURE {MERGEFIELD PhotoPath1} }}\* MERGEFORMAT}

I'm hoping that someone has tried this before and can help me navigate through this. Many thanks for your consideration.
Reply With Quote
  #2  
Old 08-02-2016, 09:16 PM
gmayor's Avatar
gmayor gmayor is offline MERGE with IF field Windows 10 MERGE with IF field Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,106
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

You need to employ the correct syntax to merge images or you will get no images or the wrong images.

See http://www.gmayor.com/mail_merge_graphics_addin.htm which shows the correct syntax and provides a means of inserting it simply.

Your construction also has an unwanted set of brackets, and the mergeformat switch is superfluous. Note that if your merge is pulling the data path from the data source, then that path must have the required double slashes for the path separators.

For copying field structures to text forums (and back to fields) you might find http://www.gmayor.com/export_field.htm useful.
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
  #3  
Old 08-03-2016, 04:24 AM
utzja1 utzja1 is offline MERGE with IF field Windows 7 64bit MERGE with IF field Office 2013
Novice
MERGE with IF field
 
Join Date: Jun 2015
Posts: 11
utzja1 is on a distinguished road
Default

Excellent, thank you! I am testing this merge before I roll it out to my inspection reports, and I created a spreadsheet with two records as the merge source, one with a photo path and one where the photo path is blank. This approach worked with the record that had a valid photo path but produced an error message for the second path (which was blank). Is there an additional result to the Boolean evaluation that needs to be provided if the IF TRUE statement is false (i.e., no path exists)?
Reply With Quote
  #4  
Old 08-03-2016, 04:33 AM
gmayor's Avatar
gmayor gmayor is offline MERGE with IF field Windows 10 MERGE with IF field Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,106
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

You can add "" if you like but it shouldn't really be necessary.

{ IF {Mergefield Condition } <> "" "Do This" "Else Do This" }
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
  #5  
Old 08-03-2016, 04:36 AM
utzja1 utzja1 is offline MERGE with IF field Windows 7 64bit MERGE with IF field Office 2013
Novice
MERGE with IF field
 
Join Date: Jun 2015
Posts: 11
utzja1 is on a distinguished road
Default

Thanks! I just found your webpage with this exact problem spelled out. I just saved a Blank.jpg and will try that route. I figure that will accomplish what I'm trying to do and remove the error message at the same time. Thanks so much for your assistance.
Reply With Quote
  #6  
Old 08-03-2016, 05:42 AM
utzja1 utzja1 is offline MERGE with IF field Windows 7 64bit MERGE with IF field Office 2013
Novice
MERGE with IF field
 
Join Date: Jun 2015
Posts: 11
utzja1 is on a distinguished road
Default

Tripped up by syntax again. I used the approach from your webpage to produce the following statement.

{INCLUDEPICTURE {IF {MERGEFIELD PhotoPath1} <> "" {MERGEFIELD PhotoPath1} "Q:\\.....\\Blank.jpg"}}

When I merge the test file, the first record merges fine and the picture displays perfectly. For the second record, this syntax gives me an error message (filename not specified). When I hit Alt-F9 to display the field in the merged document, it shows the path on the Q: drive without any quotation marks. If I add an extra set of quotation marks for the Blank.jpg file path, then it returns a blank file path and I still get the error message. Any ideas where I went astray?

Thanks.
Reply With Quote
  #7  
Old 08-03-2016, 08:52 PM
gmayor's Avatar
gmayor gmayor is offline MERGE with IF field Windows 10 MERGE with IF field Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,106
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

You didn't find that construction on my web site. What you may have found is

{INCLUDEPICTURE {IF TRUE "{Mergefield Path}{Mergefield Image}.jpg"} \d }
or in your case
{INCLUDEPICTURE {IF TRUE "{Mergefield PhotoPath}Blank.jpg"} \d }

This requires that the image is present at the path set in {Mergefield PhotoPath}. To add the conditional field, that must go outside the construction thus

{ IF {Mergefield PhotoPath} <> "" "{INCLUDEPICTURE {IF TRUE "{Mergefield PhotoPath}Blank.jpg"} \d }" "" }

Mergefield Photopath must return "Q:\\Path\\" without the filename

See also http://www.gmayor.com/mail_merge_graphics_addin.htm
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
  #8  
Old 08-04-2016, 05:30 AM
utzja1 utzja1 is offline MERGE with IF field Windows 7 64bit MERGE with IF field Office 2013
Novice
MERGE with IF field
 
Join Date: Jun 2015
Posts: 11
utzja1 is on a distinguished road
Default

Still getting the "Filename not specified" error. To clarify, the field PhotoPath1 includes the path and the target, perhaps I didn't explain that clearly. From that, my current syntax is:

{IF {MERGEFIELD PhotoPath1} <> "" "{INCLUDEPICTURE {IF TRUE {MERGEFIELD PhotoPath1}}}" ""}

Developing flat-head syndrome here. Anything jump out at you from this construction?
Reply With Quote
  #9  
Old 08-04-2016, 08:51 PM
gmayor's Avatar
gmayor gmayor is offline MERGE with IF field Windows 10 MERGE with IF field Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,106
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

What does {MERGEFIELD PhotoPath1} alone produce?
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
  #10  
Old 08-05-2016, 04:25 AM
utzja1 utzja1 is offline MERGE with IF field Windows 7 64bit MERGE with IF field Office 2013
Novice
MERGE with IF field
 
Join Date: Jun 2015
Posts: 11
utzja1 is on a distinguished road
Default

The field PhotoPath1 comes from a query that pulls the actual file path, adds the quotation marks and replaces the slash with a double slash. So {MERGFIELD PhotoPath1} produces:

"Q:\\RVA\\00-Structures\\Henrico 2015 Traffic Pole Inspxn\\Inspection Photos\\2015_1105_Base Inspections (Utz and Mercogliano)\\PB050025.JPG"
Reply With Quote
  #11  
Old 08-05-2016, 04:55 AM
utzja1 utzja1 is offline MERGE with IF field Windows 7 64bit MERGE with IF field Office 2013
Novice
MERGE with IF field
 
Join Date: Jun 2015
Posts: 11
utzja1 is on a distinguished road
Default

OK, I seem to have found a workaround that posts the blank jpg and eliminates the error message. I went into the merge source file and added the Blank.jpg file path as a merge field. It seems a little clumsy since every file will have it, but entering the path into the conditional field produced the "Filename not specified" error. Here's the syntax that finally worked:

{INCLUDEPICTURE {IF {MERGEFIELD PhotoPath1} <> "" {MERGEFIELD PhotoPath1} {MERGEFIELD PhotoBlank}}}

For whatever reason, if I don't use the PhotoBlank merge field and instead enter "Q:\\........\\Blank.jpg", I get the error message. When I hit Alt-F9 to show the fields, WORD has removed the quotation marks around the file path and thus the error. If you have a more elegant solution, I am more than willing to entertain it but I can work with this, I think. Your patience and willingness to help is greatly appreciated.
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
MERGE with IF field Merge Field Not Populating JennEx Mail Merge 8 03-31-2016 06:30 PM
Mail merge how to link mail merge field value to a column heading dsummers Mail Merge 1 05-08-2014 02:59 PM
Date field inserting merge date in blank field Lesley Mail Merge 5 09-30-2013 01:49 AM
MERGE with IF field How to ignore a mail merge field if the field is blank redzan Mail Merge 1 05-16-2013 08:34 AM
Merge field source data field kckay Mail Merge 4 03-25-2013 11:06 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 03:12 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft