![]() |
#1
|
|||
|
|||
![]() My templates have custom properties for things like course number, course title, etc., and fields in the headers and footers that reference the docproperties. This is the way we did it when I was working in Word 2003. I had to hit the ground running when I moved to a 2007 environment and I haven't had time to learn about QuickParts, which I assume would get me the same result. But everything is working as intended -- my users are ecstatic that they don't have to fight with typing inside the headers and footers any more (and so far they're complying with my dire warnings about messing with the section breaks, so the headers and footers actually work correctly!) So for the moment I'm sticking with this strategy. But I'm running into a problem with "conditional text" using the IF field. I want to insert the string "(Instructor)" in the footer IF the _Instructor docproperty is set to Yes (it's a Yes/No field), and insert nothing if it's set to No. According to the only documentation I can find (Examples of IF fields for Word 2003), it looks to me like this should work: { IF {DOCPROPERTY _Instructor} = Yes "(Instructor)" " " \* MERGEFORMAT }But it returns this: _Instructor}which is obviously not what I want. Putting "Yes" in quotes doesn't help; putting the field name in quotes doesn't help (although my simple DocProperty fields in the header and footer DO have the field name in quotes). I feel like this should be a simple thing to do...I can't understand what I'm missing. Any thoughts? Thanks in advance! Caroline |
#2
|
|||
|
|||
![]()
I realized that the example actually had spaces inside the nested brackets
{ DOCPROPERTY = _Instructor }instead of {DOCPROPERTY = _Instructor}.When I make this change and update the field, I get DOCPROPERTYinstead of _Instructor}Not sure if this is progress or not... ![]() |
#3
|
|||
|
|||
![]()
Wow.
1. When a Yes or No property is set to "Yes," the expression to compare it to is "Y," not "Yes." I hadn't gotten around to researching that particular question yet... 2. The nested brackets ( "{ DOCPROPERTY "_Instructor" } aren't just any curly braces -- they have to be Word's magic field brackets created using Insert -> Field. So. In case this will be of use to anyone else, here's the way to display conditional text using document properties and field codes: { IF { DOCPROPERTY "_Instructor" } = "Y" "(Instructor)" " " \* MERGEFORMAT }where all the brackets are magic and all the spaces are essential. ![]() Thanks for a forum where I could puzzle this out myself! Caroline |
#4
|
||||
|
||||
![]()
Hi Caroline,
Glad to see you got it sorted. Whenever you see text representations of field codes, with the '{ }' or '« »', that almost invariably means you need to insert a real field at that point. The chevrons (ie '« »') represent mergefields as they appear when inserted from the mailmerge toolbar There is another way, other than using Insert|Field for creating fields, and that's to press Ctrl-F9. For your particular example, you could simply press Ctrl-F9 twice to create a pair of nested fields (ie '{ { } }'), then fill in/around the field braces with the required expressions. And, if you find a complex field that you want to re-create, head over to: http://www.gmayor.com/export_field.htm#TextToField for a macro I developed to convert the text representation to a working field. FWIW, you don't need the \* MERGEFORMAT switch, either.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#5
|
|||
|
|||
![]()
Paul, thank you!
I used to use Ctrl + F9 constantly as an indexer, but I had completely forgotten it (I didn't know I was that good at compartmentalizing!) Of course! & thanks for the tip about the MERGEFORMAT switch. So just for future reference, would QuickParts give me an easier way to automate the header and footer content than having my users go into the Properties dialog (which is not quite as easy to get to in 2007), and then manually updating the headers and footers? Luckily I've got some pretty savvy users at the moment, but these templates will eventually go out to contractors, and I can't guarantee they'll all read the instructions. The more foolproof I can make this, the better! Thanks again, Caroline |
#6
|
||||
|
||||
![]() Quote:
However, there may be another way of meeting your needs. If you have, say, a title page where all the details you want to have appear in the Header/Footer can go in one or more paragraphs with their own unique Styles applied, then you could use StyleRef fields in the Header/Footer to replicate those details. For example, you might create a 'character' Style named 'Instructor' spanning a MACROBUTTON field coded as: {MACROBUTTON NoMacro Type the Instructor Name here} and a STYLEREF field in the header coded as: {STYLEREF Instructor} The MACROBUTTON field will appear in the document as 'Type the Instructor Name here' and, as soon as the user starts typing there, will be deleted and replaced by whatever they type. Simultaneously, the header contents will update with the same data. You could have multiple such MACROBUTTON fields with their own Styles and corresponding STYLEREF field in the header or footer. There are other ways of doing the same kind of thing without MACROBUTTON fields (eg a table with various cells formatted in the relevant Styles), but I thought you might be interested in this way.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
BluRay | Mail Merge | 5 | 03-29-2011 01:06 AM |
![]() |
Medievalguy88 | Word | 2 | 01-06-2011 08:19 AM |
![]() |
amym | Mail Merge | 1 | 12-07-2010 05:14 AM |
Mail merge Field Code Manipulation | macjnr | Mail Merge | 0 | 09-10-2009 11:37 AM |
![]() |
oreomax | Mail Merge | 3 | 06-16-2009 06:53 AM |