#1
|
|||
|
|||
Tables in IF blocks returning empty row as opposed to nothing
Hi, this is my first post so apologies if I have mis-posted it.
Here's the issue I'm currently facing. I have created a Word 2013 mailmerge file, which gets its fields from an Excel sheet. Then the resulting file is uploaded to a web server and a .NET application replaces the fields from the DB. The following structure is included in the file: { IF { MERGEFIELD FieldName1 } <> "" "<table><tr><td>ColName1</td><td>ColValue1</td></tr></table>" "" } { IF { MERGEFIELD FieldName2 } <> "" "<table><tr><td>ColName2</td><td>ColValue2</td></tr></table>" "" } { IF { MERGEFIELD FieldName3 } <> "" "<table><tr><td>ColName3</td><td>ColValue3</td></tr></table>" "" } NOTE: I have used HTML tags to explain the layout, though the tables are created in Word. Everything works great and the tables are stuck together, creating a contiguous block of text when all values are being returned. The problem is when one of the values (eg. FieldName2) does not get returned, so the conditional statement should not display the table at all and stick the next table underneath, but instead a new line is introduced. So the result is that there's an empty line between the tables. I'm trying to remove this line but have had no luck. I viewed the source code of the received email, and it seems that there's an extra <p style="margin:0pt"></p> being inserted between the tables. Let me know if you would need anything else from me... Any help would be appreciated. Thanks d |
#2
|
||||
|
||||
It appears from your code that you have line/paragraph breaks between each of the field sets. Instead of:
{ IF { MERGEFIELD FieldName1 } <> "" "<table><tr><td>ColName1</td><td>ColValue1</td></tr></table>" "" }¶ { IF { MERGEFIELD FieldName2 } <> "" "<table><tr><td>ColName2</td><td>ColValue2</td></tr></table>" "" }¶ { IF { MERGEFIELD FieldName3 } <> "" "<table><tr><td>ColName3</td><td>ColValue3</td></tr></table>" "" }¶ you should have: { IF { MERGEFIELD FieldName1 } <> "" "<table><tr><td>ColName1</td><td>ColValue1</td></tr></table>" "" }{ IF { MERGEFIELD FieldName2 } <> "" "¶ <table><tr><td>ColName2</td><td>ColValue2</td></tr></table>" "" }{ IF { MERGEFIELD FieldName3 } <> "" "¶ <table><tr><td>ColName3</td><td>ColValue3</td></tr></table>" "" }¶ where ¶ is your line/paragraph break.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Macro to delete all empty rows from all tables | braddgood | Word VBA | 15 | 10-02-2015 01:54 PM |
What is purpose of slide master, as opposed to slide layout | meileetan | PowerPoint | 3 | 01-10-2014 02:20 AM |
Can you create a bibliography (as opposed to a table of authorities) in Word 2003? | New Daddy | Word | 1 | 11-06-2012 02:37 AM |
Apparently empty (blank) cells aren't empty | daymaker | Excel | 3 | 03-08-2012 03:41 PM |
compatibility mode VS saving to doc as opposed to docx | airtas | Word | 7 | 05-30-2010 02:19 PM |