Hi all
I have a workbook, where when opened, I need to log the user, date and time of opening, and then save the event.
The event is written to a sheet hidden from the user named "User_Data"
Simple 2 lines of code to achieve this:-
I have a workbook, where when opened, I need to log the user, date and time of opening, and then save the event.
The event is written to a sheet hidden from the user named "User_Data"
Simple 2 lines of code to achieve this:-
Code:
[FONT=Calibri][COLOR=#000000]Sub Workbook_Open()
Sheets("User_Date").Range("A" &Rows.Count).End(xlUp).Offset(1).Value = Application.UserName & "" & Now()
[/COLOR][/FONT]
[FONT=Calibri][COLOR=#000000]ThisWorkbook.Save
End Sub
[/COLOR][/FONT]
When I run this, I am getting the Run-time 1004 error.
As it is an open workbook event, I am unable to test without reopening the book, so i took the code out and placed it into a seperate sub and called the seperate sub from the Workbook open event.
Still it falls over on initialisation, yet i can manually step through the Sub Id_Date code a second time around sucessfully?
What am I doing wrong?
Thanks in advance
John
As it is an open workbook event, I am unable to test without reopening the book, so i took the code out and placed it into a seperate sub and called the seperate sub from the Workbook open event.
Still it falls over on initialisation, yet i can manually step through the Sub Id_Date code a second time around sucessfully?
Code:
[FONT=Calibri][COLOR=#000000]Sub Workbook_Open()[/COLOR][/FONT]
[FONT=Calibri][COLOR=#000000]Call Id_Date[/COLOR][/FONT]
[FONT=Calibri][COLOR=#000000]End Sub[/COLOR][/FONT]
[FONT=Calibri][COLOR=#000000]_________________________________________________________________________________[/COLOR][/FONT]
[FONT=Calibri][COLOR=#000000]
Sub Id_Date()[/COLOR][/FONT]
[FONT=Calibri][COLOR=#000000]Sheets("User_Date").Range("A" &Rows.Count).End(xlUp).Offset(1).Value = Application.UserName & "" & Now()[/COLOR][/FONT]
[FONT=Calibri][COLOR=#000000]ThisWorkbook.Save[/COLOR][/FONT]
[FONT=Calibri][COLOR=#000000]End Sub[/COLOR][/FONT]
What am I doing wrong?
Thanks in advance
John