Microsoft Office Forums Insert date when save file

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 01-28-2011, 07:00 PM
gg80 gg80 is offline Insert date when save file Windows 7 Insert date when save file Office 2007
Novice
Insert date when save file
 
Join Date: Jul 2010
Location: Berkeley, CA
Posts: 9
gg80 is on a distinguished road
Default Insert date when save file

I want to insert the save date in a cell whenever the file is saved. I got this code from google search:

Option Explicit
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)


Sheets("Sheet1").Range("A1").Value = Format(Now(), "mm-dd-yy")
End Sub

It works great on excel 2003, but not in excel 2007 (running under W7).

I googled to get the above, but found nada about something specific for 2007.

Any help much appreciated
Reply With Quote
  #2  
Old 01-28-2011, 08:01 PM
macropod's Avatar
macropod macropod is offline Insert date when save file Windows 7 32bit Insert date when save file Office 2000
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 19,661
macropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to behold
Default

Hi gg80,

That code should work exactly the same in Excel 2007.
__________________
Cheers,
Paul Edstein
[MS MVP - Word]
Reply With Quote
  #3  
Old 01-29-2011, 02:48 AM
Colin Legg's Avatar
Colin Legg Colin Legg is offline Insert date when save file Windows 7 32bit Insert date when save file Office 2010 32bit
Expert
 
Join Date: Jan 2011
Location: UK
Posts: 369
Colin Legg will become famous soon enough
Default

Hello,
Quote:
It works great on excel 2003, but not in excel 2007 (running under W7).
In what way isn't the code working? Do you get an error or does it just appear not to do anything?

If it doesn't seem to be doing anything, make sure that:
(1) the code is in the ThisWorkbook class module of the workbook
(2) macros are enabled
(3) events are enabled (type Application.EnableEvents=True into the immediate window)

If it gives you a runtime error then please give us the details of the error. It could be the case that
(1) a sheet called Sheet1 doesn't exist
(2) Sheet1 is protected.

Hope that helps...
Reply With Quote
  #4  
Old 01-29-2011, 08:36 AM
gg80 gg80 is offline Insert date when save file Windows 7 Insert date when save file Office 2007
Novice
Insert date when save file
 
Join Date: Jul 2010
Location: Berkeley, CA
Posts: 9
gg80 is on a distinguished road
Default

Head slap! I entered code in excel 2003, it worked, and I expected it to work in excel 2007. I didn't know about "enabling macros". Thanks very much-problem solved.
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Insert date when save file How to update automatically the “file name” as we do for the “Date”? Jamal NUMAN Word 2 01-06-2011 02:43 PM
Insert date when save file Word Macro: Save file as text with current file name jabberwocky12 Word VBA 2 10-22-2010 12:23 PM
How to save file on CD? DennisWG Word 0 09-07-2010 10:41 AM
How to insert a .mov file in Word Document Jai25 Word 0 02-11-2010 04:40 PM
Trying to insert hyperlink to excel file into Outlook KarenE Outlook 0 05-08-2006 12:56 PM


All times are GMT -7. The time now is 11:22 PM.


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