Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 04-04-2020, 03:22 PM
eduzs eduzs is offline Advanced field coding, given date instead of today. Windows 10 Advanced field coding, given date instead of today. Office 2019
Expert
Advanced field coding, given date instead of today.
 
Join Date: May 2017
Posts: 260
eduzs is on a distinguished road
Default Advanced field coding, given date instead of today.

I have this field code that works fine:

Code:
{ SET xM{ = { DOCVARIABLE dt1 \@ M}} }{ SET xMM{ = { DOCVARIABLE dt1 \@ MM}} }{ SET xY{ = { DOCVARIABLE dt1 \@ yyyy}} }

{ QUOTE { SET Delay 1 } { SET m { =MOD({ xMM }+Delay+11;12)+1 } }{ SET y { =INT({ xY }+(Delay+{ xM }-1)/12) } } “{ m }-{ y }” \@ “MMMM/yyyy” }
But I want to define a variable to repeat the field elsewhere in the document, saving space / lines (no need to repeat this long field code).



I tried this:

Code:
{ SET xDate{={ QUOTE { SET Delay 1 } { SET m { =MOD({ xMM }+Delay+11;12)+1 } }{ SET y { =INT({ xY }+(Delay+{ xM }-1)/12) } } “{ m }-{ y }” \@ “MMMM/yyyy” }}}
{ xDate \@ “MMMM/yyyy” }
But this returns an error: unexpected end of formula.

Thanks in advance

Last edited by eduzs; 04-04-2020 at 05:58 PM.
Reply With Quote
  #2  
Old 04-04-2020, 04:55 PM
macropod's Avatar
macropod macropod is offline Advanced field coding, given date instead of today. Windows 7 64bit Advanced field coding, given date instead of today. Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Instead of:
{ SET xDate{={ QUOTE { SET Delay 1 } { SET m { =MOD({ xMM }+Delay+11;12)+1 } }{ SET y { =INT({ xY }+(Delay+{ xM }-1)/12) } } “{ m }-{ y }” \@ “MMMM/yyyy” }}}
{ xDate \@ “MMMM/yyyy” }
use:
{SET xDate{QUOTE{SET Delay 1}{SET m{=MOD({xMM}+Delay+11;12)+1 }}{SET y{=INT({ xY }+(Delay+{ xM }-1)/12)}} "{ m }-{ y }" \@ "MMMM/yyyy"}}
{REF xDate }

That said, it would be far simpler just to bookmark the first output then cross-reference that bookmark.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 04-04-2020, 05:55 PM
eduzs eduzs is offline Advanced field coding, given date instead of today. Windows 10 Advanced field coding, given date instead of today. Office 2019
Expert
Advanced field coding, given date instead of today.
 
Join Date: May 2017
Posts: 260
eduzs is on a distinguished road
Default

Thanks macropod! Works fine!
I found that the second line works with or without "REF".
Also thanks for "WORD Date & Time Manipulation: Tips & Techniques" which helped a lot.
Reply With Quote
  #4  
Old 04-04-2020, 06:25 PM
macropod's Avatar
macropod macropod is offline Advanced field coding, given date instead of today. Windows 7 64bit Advanced field coding, given date instead of today. Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Quote:
Originally Posted by eduzs View Post
I found that the second line works with or without "REF".
True, but cross-references - which is what you are using - should nevertheless be prefixed with REF. In any event, if you bookmark the result (whether via the SET field or by bookmarking the output) and cross-reference it via Insert|Cross-Reference, Word will always insert the REF part.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Change font color if date in column F is prior to today's date. kevinbradley57 Excel Programming 1 12-05-2018 07:35 PM
Advanced field coding, given date instead of today. Nested If Statements in Formula Field to Produce the Diffrnc in Years Between Today's & Entered Date mshu31 Word 1 02-09-2017 02:04 PM
Advanced field coding, given date instead of today. Today's Date Function freschij Excel 3 02-11-2011 10:21 AM
new appointment date always reverts back to today's date msills Outlook 0 08-24-2007 08:57 AM
Advanced field coding, given date instead of today. Imported message date change to today's date promark Outlook 1 12-23-2005 07:21 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 07:49 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft