Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel 2000: How to display full path and DateCreated in cell? 1

Status
Not open for further replies.
Oct 6, 2000
7
US
I need to have a cell in an Excel worksheet display the full path of the file and the date the file was created or maybe modified. I've worked with VBA in Access, but never in Excel.
 
You can add this code to the sheet's object. This is for the complete path and filename. I am not sure how to get the date the file was originally created.
Code:
Private Sub Worksheet_Activate()
    Range("A1").FormulaR1C1 = ThisWorkbook.FullName
End Sub
 
Thanks, but why does it display the old location after I move it then open it again? If I go to other worksheets then back to the Sheet1 the location refreshes. When does this Worksheet Activate event fire if not on the opening of the Workbook?
 
That subroutine runs when the worksheet is activated (upon switching sheets). If you want this to update only once, when the workbook is opened, add this code to a module (not the sheet object).
Code:
Sub Auto_Open()
    Range("A1").FormulaR1C1 = ThisWorkbook.FullName
End Sub
I am sure that there is a way to get the file creation date, but I am not sure exactly how. I will poke around, but in the meantime, I am sure that one of the other experts in this forum can help.
 
That's closer. This is how I rewrote it:
In a module for the ThisWorkbook object

Private Sub Workbook_Open()
Sheet1.Range("A2").FormulaR1C1 = ThisWorkbook.FullName
End Sub

It doesn't matter if the user renames Sheet1 or the cell A2 as these are absolute references.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top