Calculating a page number using Field and Function

New Contributor

Problem: In Word 2013, I want to add a final line to a Contents list for something that is not in the Word document, but will be added manually after printing. [The Contents list is NOT generated by using any Word methods, and it is not in a Table]

 

The previous-to-last entry is

APPENDIX 14: xxxxxxxxx .................................   { PageRef APPENDIX_14 }

The page number for the above works.  

The last line of the Contents is

ADDITIONAL MATERIAL ........................................ {  ={ PageRef APPENDIX_14} + x }

If  page number for Appendix_14 is an odd number, then x should be 2, otherwise x should be 1.

I tried using the MOD function to determine even or odd:

{ IF { MOD ( PageRef APPENDIX_14, 2) = 0  { ={ PageRef APPENDIX_14 } + 1 }  { ={ PageRef APPENDIX_14 } + 2 } } }

but nothing is displayed and no syntax error. is shown. What am I missing?

Thank you.

Chris

4 Replies

@cpkaway 

You need to use

{ IF { = MOD({ PAGEREF Appendix_14 },2) } = 1 { = { PAGEREF Appendix_14 } + 2} { = { PAGEREF Appendix_14 } + 1 } }

You must use CTRL+F9 to insert each pair of field delimiters { }

 

Doug_Robbins_Word_MVP_0-1641804151946.png

 

Thank you very much Doug for your help. I struggled with this for a long time.
Just in case someone copies the above formula, there is a missing closing brace after the + 2. The formula in the clip is correct, the brace was just omitted when transcribed. The correct version which matches the clip is:
{ IF { = MOD({ PAGEREF Appendix_14 },2) } = 1 { = { PAGEREF Appendix_14 } + 2 } { = { PAGEREF Appendix_14 } + 1 } }
I have tested it using odd and even pages, and it works perfectly. Thanks again Doug.
Thanks, I have corrected the typo in my original response.