Update Date - On Print?

Experts,

I have a hard coded date on a sheet.
I would like for the date to be updated upon print.
How can I do this?  

Not sure if there is something "canned" inside of Excel for this.  
I am using 2k7.

thank you
pdvsaProject financeAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

kgerbChief EngineerCommented:
Put this in the workbook code module.  Replace "Sheet1" and "A1" with appropriate sheet name and range.

Private Sub Workbook_BeforePrint(Cancel As Boolean)
Sheets("Sheet1").Range("A1") = Now()
End Sub

Open in new window

Kyle
0
pdvsaProject financeAuthor Commented:
Hi Kyle, sorry for not getting back earlier.   Was jam packed with work from real job.   Getting back to the question.  If i have a range set in the sheet and within that range there is a cell with a date then i think you are saying the cell with a date will be updated?   Thank you...  Do you happen to know hiw to do this without code?  I ask because i believe i would have to save as a macro enabled file.
0
kgerbChief EngineerCommented:
Without macros there is really no way to make sure the update ONLY happens before a print event.  You have several other options though.  You could use a formula like

=Today()

in your cell.  Then just make sure the workbook has recalculated before you print.  Or you could put a date in header/footer.  This will auto-update.

Other than that there aren't many other options.  How exactly are you trying to update the cell?  I'm going on the assumption that you want the current date before the document is printed.  Even if this is not the case we might be able to come up with a formula to suit your needs.

Kyle
0
Learn Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

pdvsaProject financeAuthor Commented:
Kyle, I forgot about this question.  Sorry.  past few days have been very busy.

Is it true that if I put =Today() then once I open the file the date will be overridden?  If I dont save the file then there will be no changes.  I am looking for no update of the date unless I print.  

Example:  if I have a file with a lable such as "Date Printed" and open the file, the date printed would be changed to the current date if I use Today().

Not sure if I am making sense or you already covered it.  

thank you...
0
kgerbChief EngineerCommented:
pdvsa,
The code provide in my first post will insert static text into the cell.  It will not update, ever, unless you print.  That's what the BeforePrint Event does.  It only fires when you print.  So you can do anything you want to the workbook, the date will not change until you print.  Let me know if you have further questions.

Kyle
0
pdvsaProject financeAuthor Commented:
Hi Kyle, my only issue with vba is that the other users if the file will not know what to do once they get the security message to enable macros.  

I was thinking that there could be fields much like in ms word that you can insert and apply a sort of code within excel without vba.  

Do you know what i am talking about?  

Thank you
0
kgerbChief EngineerCommented:
pdvsa,
I'm not sure what else to tell you.  Here are your options, which I will state again.

1.  VBA BeforePrint event.  Will fire before printing so date will only update before printing.
2.  Formula in worksheet.  Date functions are volatile so they will fire whenever the worksheet is recalculated.  If you want to enter today's date in a non-volatile way do Ctrl+;.  This is static and will not update before printing.
3.  Put a date code in the header of the worksheet.  This will only update when printed.  I think this might be your best bet.  If you need help with this let me know.

Excel does have "fields" like in Word.  In fact it has 17,179,869,184 of them (per worksheet) :-).

All joking aside.  I'm sorry this isn't the answer you were looking for but, like I said, I'm not sure what else to say, these are pretty much your options.  There may be some obscure Excel 4 macro out there but that was way before my time.

Kyle
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
pdvsaProject financeAuthor Commented:
Ok thank you.  It wasnt exactly what I was looking for but I will tell the other users to enable the macros on open or make a trusted area to avoid having to enable them each time you open teh file.  thank you Kyle.  I didnt mean to be difficult.
0
kgerbChief EngineerCommented:
No problem.  I'm sorry I wasn't able to come up with a better solution for you.  If you want to take the time, you may want to ask another question and link to this one.  I am by no means the final authority on Excel.  There are plenty of MVP's that frequent this TA.  One of them might be able to give you exactly what you want.  If that happens I will be happy to get a mod to refund your points and withdraw this Q from the knowledge base.

Kyle
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.