When was the file opened last time

Overkill32

New Member
Joined
May 13, 2011
Messages
49
Is there a way (function or macro) to get the time or date that a specific file was opened (not saved)?

Thanks for the help
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
You are going to have to decide where you want the date/time stored at, but you can use the workbook's Open event to store the results of the VB Now function. For example, if you chose to store it in A1 on Sheet1, the event code would look like this...
Code:
Private Sub Workbook_Open()
  Worksheets("Sheet1").Range("A1").Value = Now
End Sub
You would store this code in the ThisWorkbook module (double-click that item in the Project window in the VB editor and put the code in the code window that opens up).
 
Upvote 0
The only way i could see this working is to use the Now function only when the workbook close so the range() that the value is assigned for will display the last time opened... Is there a private sub workbook_close() that exist??
 
Upvote 0
In that case, store the Now value in a global variable during the workbook Open event and write that value out to the cell in the Close event. To create a global variable, Dim the variable at the top of the sheet module (this Dim statement stands on it own... do not put it inside any procedures). So, you would have something like this in the sheet module...
Code:
Dim ThisWorkbooksOpenDateTime As Date
 
Private Sub Workbook_Open()
  ThisWorkbooksOpenDateTime = Now
End Sub
 
Private Sub Workbook_BeforeClose(Cancel As Boolean)
  Worksheets("Sheet1").Range("A1").Value = ThisWorkbooksOpenDateTime
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,514
Messages
6,179,220
Members
452,895
Latest member
BILLING GUY

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top