Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Disregard contents mergefields 3

Status
Not open for further replies.

Jdubs

Technical User
Apr 3, 2003
11
GB
Hi

I'm compiling a merged contracts document in Word 2003 fed from an Excel spreadsheet. I'm using the if ..then ..else functionaility to ecide whihc clauses have to be included in the contract.

My problem is if a there are a numebr of clause in a row which an employee isn't eligable for, when the document is merged a number of blank lines appear.

Is it possible to surpress these lines?

Thanks
 
Hi Jdubs,

I found this in Word's Help menu. Maybe it answers your question.

To prevent blanks lines with Microsoft Word fields such as IF, SET, and ASK, do the following:

If a field (such as ASK or SET) has no resulting text, you can insert the field within the standard text. If you must place the field in a separate paragraph, format the paragraph mark () as hidden text. Before you merge the documents, clear the Hidden text check box on the Print tab in the Options dialog box (Tools menu).
If text inserted by an IF field must be printed in a separate paragraph, include the paragraph mark in the field instructions. Insert the IF field in the main document; then, with field codes displayed, insert the paragraph mark within the appropriate set of quotation marks. In the following example, Word inserts the paragraph mark that follows "brochure" only if the text is printed.
{ IF { MERGEFIELD Product } = "Pasta" "We have expanded our line of pasta products. Please see the enclosed brochure.

" " " } Thank you for your order.


Hope this helps,


Best,
Blue Horizon [2thumbsup]
 
Hi

Unfortunatley that's the format my MERGEFIELD are setup as. My problems lie I suppose around having a number of clause together, if they are all referenced then it looks OK but when they aren't the spaces between the clauses group together.

Perhaps the answer would be to write a VBA routine to delete lines if there are more then 2 together from a fixed point in the document.

Thanks for you help though

Cheers
Jon
 
Hi Jdubs,

The solution is quite like the one stubnski pointed you to. In this case, though, you insert the text for the clause into multiple IF tests, along the lines of:
Code:
{IF«Clause1»= "" "" "¶Clause 1 Text goes here"}{IF«Clause2»= "" "" "¶Clause 2 Text goes here"}{IF«Clause3»= "" "" "¶Clause 3 Text goes here"}{IF«Clause4»= "" "" "¶Clause 4 Text goes here"}
or
Code:
{IF«Clause1»= "" "" "Clause 1 Text goes here¶"}{IF«Clause2»= "" "" "Clause 2 Text goes here¶"}{IF«Clause3»= "" "" "Clause 3 Text goes here¶"}{IF«Clause4»= "" "" "Clause 4 Text goes here¶"}
depending on whether you prefer to attach the mergefield to the previous or following paragraph. In either case, the important point to note is that all these mergefields go onto one logical line in Word (ie word-wrap aside).

Cheers

[MS MVP - Word]
 
Hi - Thanks for all your help - things are getting better.
I've had a slight change of plan and am now merging all the documents from access - Example below

«sales_commission_header»
«Sales_Commission_clause_1» «Total_On_Target_Earning» «sales_Commission_clause_2» «OTE» «sales_Commision_clause_3»
«Bonus_header»«clause_1» «All_bonusBonus_» «clause_2»
«Shift_Allownace_Headrer»
«Shift_Allowance_Clause1» «Shift_» «Shift_Allowance_Clause_2»
«Inconvenience_Header»
«Inconvenience_Clause»
«CAllout_Header»
«CAllout_Clause_1» «Standby_Callout»«CAllout_Clause_2»
«Out_of_Hour_Header»
«Out_Of_Hours_Clause»

This works fine but I need way of adding blank rows between the clauses to stop them blocking together.

I don't want to inset them manually since if an employee isn't eligable for all clauses I get a number of blank lines.

I have thought about adding a row of text and then coloring it white but I'm sure there must be a more elegant solution.

Any thoughts would eb appreciated.

Thanks
 
Hi Jdubs,

The change in data source doesn't change the solution!

Cheers

[MS MVP - Word]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top