Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
jk jk is offline
external usenet poster
 
Posts: 109
Default Current Date & Save on close

I need to have some code so when the users open the workbook, the current
date would be inserted into cell A1. Then, after the workbook has been used,
an auto save on close in case they forget to use the save menu option. Can
these two things be done?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Current Date & Save on close

Option Explicit

Private Sub Workbook_BeforeClose(Cancel As Boolean)
ThisWorkbook.Save
End Sub

Private Sub Workbook_Open()
Worksheets(1).Range("A1").Value = Date
End Sub

'This is workbook event code.
'To input this code, right click on the Excel icon on the worksheet
'(or next to the File menu if you maximise your workbooks),
'select View Code from the menu, and paste the code


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"jk" wrote in message
...
I need to have some code so when the users open the workbook, the current
date would be inserted into cell A1. Then, after the workbook has been

used,
an auto save on close in case they forget to use the save menu option. Can
these two things be done?



  #3   Report Post  
Posted to microsoft.public.excel.programming
jk jk is offline
external usenet poster
 
Posts: 109
Default Current Date & Save on close

Thanks Bob,

This works well. In the event a user wants to save the file as another name
to the desktop, can a "save as" prompt appear to save on close?

"Bob Phillips" wrote:

Option Explicit

Private Sub Workbook_BeforeClose(Cancel As Boolean)
ThisWorkbook.Save
End Sub

Private Sub Workbook_Open()
Worksheets(1).Range("A1").Value = Date
End Sub

'This is workbook event code.
'To input this code, right click on the Excel icon on the worksheet
'(or next to the File menu if you maximise your workbooks),
'select View Code from the menu, and paste the code


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"jk" wrote in message
...
I need to have some code so when the users open the workbook, the current
date would be inserted into cell A1. Then, after the workbook has been

used,
an auto save on close in case they forget to use the save menu option. Can
these two things be done?




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
save a file with current date inserted automatically Budster Excel Programming 1 July 20th 06 04:55 AM
save workbook as current date using a macro ExcelJon Excel Discussion (Misc queries) 2 June 21st 06 03:05 AM
Save File with the current date and time. sd Excel Programming 2 December 2nd 05 12:33 PM
Save as Current Date / Time Jacob_F_Roecker Excel Discussion (Misc queries) 1 October 25th 05 09:37 AM
Save Workbook as Current Date/Time Jacob_F_Roecker Excel Discussion (Misc queries) 1 October 25th 05 09:37 AM


All times are GMT +1. The time now is 06:42 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"