ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Date of Last Update Automatically? (https://www.excelbanter.com/excel-programming/290894-date-last-update-automatically.html)

Crush

Date of Last Update Automatically?
 
Is there any way to have a field that will automatically
display the date of the last update?

We have a calendar online that people are questioning how
often it has been updating, so this would solve any
issues right from the start.

Thanks

Ron de Bruin

Date of Last Update Automatically?
 
Hi Crush

If you mean last saved date of the file??

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, _
Cancel As Boolean)
Sheets("Sheet1").Range("a1").Value = Date
End Sub

Right click on the Excel icon next to File in the menubar
Choose view code
Paste this event there
Alt-q to go back to Excel

If you save the file the date will be placed in A1



--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2000-2003)
www.rondebruin.nl



"Crush" wrote in message ...
Is there any way to have a field that will automatically
display the date of the last update?

We have a calendar online that people are questioning how
often it has been updating, so this would solve any
issues right from the start.

Thanks




Bob Phillips[_6_]

Date of Last Update Automatically?
 
You need VBA, but you could use a UDF. Here is an example

Function DocProps(prop As String)

On Error GoTo err_value
DocProps = ActiveWorkbook.BuiltinDocumentProperties(prop)
Exit Function

err_value:
DocProps = CVErr(xlErrValue)
End Function

Put the function in a standard code module.

and can be used like so

=DocProps("Last save time")

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Crush" wrote in message
...
Is there any way to have a field that will automatically
display the date of the last update?

We have a calendar online that people are questioning how
often it has been updating, so this would solve any
issues right from the start.

Thanks




Ron de Bruin

Date of Last Update Automatically?
 
Hi

ActiveWorkbook.BuiltinDocumentProperties
Is not working correct in Excel 97

Read this from Tom Ogilvy

Note that this property is not maintained in xl97. However, if the workbook
is created/used in both xl97 and later versions, then when used in the
later versions and saved the property is maintained but when used in xl97
and saved, the property is not altered. The time it was last saved in the
later version will be retrieved if this property is called. If created and
used exclusively in xl97, calling this property will raise an error. You
can use the beforesave event to update this property in xl97 as a
workaround. Just test the version of excel and if xl97, update the
property.



--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2000-2003)
www.rondebruin.nl



"Bob Phillips" wrote in message ...
You need VBA, but you could use a UDF. Here is an example

Function DocProps(prop As String)

On Error GoTo err_value
DocProps = ActiveWorkbook.BuiltinDocumentProperties(prop)
Exit Function

err_value:
DocProps = CVErr(xlErrValue)
End Function

Put the function in a standard code module.

and can be used like so

=DocProps("Last save time")

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Crush" wrote in message
...
Is there any way to have a field that will automatically
display the date of the last update?

We have a calendar online that people are questioning how
often it has been updating, so this would solve any
issues right from the start.

Thanks






Crush

Date of Last Update Automatically?
 
Cool. Look forward to testing it out tomorrow.
Thanks much.


-----Original Message-----
Hi Crush

If you mean last saved date of the file??

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As

Boolean, _
Cancel As Boolean)
Sheets("Sheet1").Range("a1").Value = Date
End Sub

Right click on the Excel icon next to File in the menubar
Choose view code
Paste this event there
Alt-q to go back to Excel

If you save the file the date will be placed in A1



--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2000-2003)
www.rondebruin.nl



"Crush" wrote in

message ...
Is there any way to have a field that will

automatically
display the date of the last update?

We have a calendar online that people are questioning

how
often it has been updating, so this would solve any
issues right from the start.

Thanks



.



All times are GMT +1. The time now is 10:34 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com