Saturday, November 05, 2011

Word Field Code Samples

As I mentioned in my last post, I will list down some uses of Word field codes here. If you would like to know what they are I invite you to read my previous post on field codes.

Notes -

  • Always remember to user Ctrl + F9 to put curly braces, sorry no copy pasting, you have to type all.
  • If the codes are misbehaving, right click and click on Update Field.
1. Using Word how to greet the user according to the time of the day.
 

{ If "{ Time \@ "HH:mm" }" > "12:00" { If "{ Time \@ "HH:mm" }" > "15:00" { If "{ Time \@ "HH:mm" }" > "18:00" "Good Night" "Good Evening" } "Good Afternoon" } "Good Morning" }

image

image

2. Concatenating text and displaying in Word.

Welcome { UserName } you are reading { FileName \* MergeFormat }.

image

3. Displaying page number in odd pages and text on others in Word.

{ If { =Mod({ Page }, 2) } =1 { Page } "PTO" }

image

image

4. Using Word skipping page number on first two pages and then showing page numbers starting from number 2.

{ If { Page } < 3 "" { ={ Page } - 1 } }

image

image

5. Displaying last saved user name on the last page in Word.

{ If { Page } = { NumPages } "This { FileName } was last saved by { LastSavedBy } on {DocProperty LastSavedTime }. Document was edited for { EditTime } minutes." "" }

image

6. Displaying number of characters, words, paragraphs, pages in a Word document.

This document has { NumWords } words in { NumPages } pages.

image

This document has { NumChars } characters in { DocProperty Paragraphs } paragraphs.

image

No comments: