![]() |
|
#1
|
|||
|
|||
|
Hi All
New to VBA for Word as well as forms for Word. Have created something that works great where a date is requested on file load, which then calculates dates on a form. Problem is, when we select File, Print, the dates all revert to original inputted date. Sample of prompt to get date, place got date and one calculation from got date included below (I got this last one off the internet and it calculates the prior fortnight) is attached. Couldn't work out how to copy the code and paste in here so attachment was only option (sorry). As said, everything works fine until I select File, Print. Even tried turning off "update fields when print" but made no difference. Hoping someone can shed some light on the subject. ![]() I found a macro that lets me copy out the field data. So below is the prompt to get the date to calculate from, then display the date entered, and then one of the calculations (basically each is the same except the second row changes to 12, to 11, to 10, etc, so a fortnight is done): { SET FNDATE { FILLIN "What is the Fortnight Ending (in DD/MM/YYYY format)" \@ "dd/MM/yyyy" } } { FNDATE } {QUOTE {SET Delay -13} {SET a{=INT((14-{FNDATE \@ M})/12)}} {SET b{={FNDATE \@ yyyy}+4800-a}} {SET c{={FNDATE \@ M}+12*a-3}} {SET d{FNDATE \@ d}} {SET jd{=d+INT((153*c+2)/5)+365*b+INT(b/4)-INT(b/100)+INT(b/400)-32045+Delay}} {SET e{=INT((4*(jd+32044)+3)/146097)}} {SET f{=jd+32044-INT(146097*e/4)}} {SET g{=INT((4*f+3)/1461)}} {SET h{=f-INT(1461*g/4)}} {SET i{=INT((5*h+2)/153)}} {SET dd{=h-INT((153*i+2)/5)+1}} {SET mm{=i+3-12*INT(i/10)}} {SET yy{=100*e+g-4800+INT(i/10)}} "{dd}-{mm}-{yy}" \@ " dd/MM/yyyy "} Last edited by fatal.lordes; 04-26-2018 at 06:05 PM. Reason: Added code. |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Can't reset form fields (Word 2013) and conditional formatting | rogelinepaula | Word VBA | 24 | 01-07-2016 03:54 PM |
| Extract form fields to Word Document | RonNCmale | Word VBA | 22 | 01-11-2014 05:06 AM |
Recovering a word file (Select the encoding that makes your document readable)
|
Canni | Word | 2 | 08-29-2012 02:46 PM |
Preventing Form Fields to Reset
|
PosseJohn | Word VBA | 4 | 07-15-2011 09:44 PM |
Word Macro That Checks a Check Box Form Field When File Print is Executed
|
DKerne | Word VBA | 4 | 06-09-2011 11:54 AM |