Hi - I have a excel log file held on a sharepoint site which is triggered when an excel work book is opened. The log file merely logs the username and date / time opened. I can get the file to open and populate the user name and and date /time. However when I close the file it opens the Save As Dialogue box. When you select Save it says that the file already exists and would you like to overwrite the file.
I want to suppress the Save as screen and overwrite file dialogue boxes so it happens automatically. Ideally I want all the logging to occur in the background so the user doesn't see any of this happening.
The code is as follows:-
Sub Workbook_Open()
LogDetails 'Calls subroutine to log username and date
End Sub
Sub LogDetails()
Dim LR As Long
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Workbooks.Open Filename:="http://filepath/filepath/Log%20for%20Annual%20Statement.xlsx"
Workbooks("Log for Annual Statement.xlsx").Activate
Worksheets("Log").Activate
LR = Range("A" & Rows.Count).End(xlUp).Row
Sheets("Log").Cells(LR + 1, 1) = (Environ$("Username"))
Sheets("Log").Cells(LR + 1, 2) = Now()
ActiveWorkbook.Close savechanges:=True
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub
Any ideas?
I want to suppress the Save as screen and overwrite file dialogue boxes so it happens automatically. Ideally I want all the logging to occur in the background so the user doesn't see any of this happening.
The code is as follows:-
Sub Workbook_Open()
LogDetails 'Calls subroutine to log username and date
End Sub
Sub LogDetails()
Dim LR As Long
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Workbooks.Open Filename:="http://filepath/filepath/Log%20for%20Annual%20Statement.xlsx"
Workbooks("Log for Annual Statement.xlsx").Activate
Worksheets("Log").Activate
LR = Range("A" & Rows.Count).End(xlUp).Row
Sheets("Log").Cells(LR + 1, 1) = (Environ$("Username"))
Sheets("Log").Cells(LR + 1, 2) = Now()
ActiveWorkbook.Close savechanges:=True
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub
Any ideas?