Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 04-26-2018, 05:33 PM
fatal.lordes fatal.lordes is offline Word document with VBA and Form Fields reset when select File,Print Windows 7 64bit Word document with VBA and Form Fields reset when select File,Print Office 2016
Novice
Word document with VBA and Form Fields reset when select File,Print
 
Join Date: Apr 2018
Posts: 6
fatal.lordes is on a distinguished road
Default Word document with VBA and Form Fields reset when select File,Print

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 "}
Attached Files
File Type: docx sample fields.docx (23.9 KB, 9 views)

Last edited by fatal.lordes; 04-26-2018 at 06:05 PM. Reason: Added code.
Reply With Quote
 



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
Word document with VBA and Form Fields reset when select File,Print Recovering a word file (Select the encoding that makes your document readable) Canni Word 2 08-29-2012 02:46 PM
Word document with VBA and Form Fields reset when select File,Print Preventing Form Fields to Reset PosseJohn Word VBA 4 07-15-2011 09:44 PM
Word document with VBA and Form Fields reset when select File,Print Word Macro That Checks a Check Box Form Field When File Print is Executed DKerne Word VBA 4 06-09-2011 11:54 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 09:56 AM.


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