S
SU
I am trying to prompt users with a message (when they save the file) to fill
in a cell with their LoginName.
This LoginName will be used as the filename to save the file automatically.
But I am getting program error message followed by crashing of Excel.
Please help and advice. Also, can I automate the same process to save the
file in a specific folder?
Many thanks in advance.
Here is the code that I am using below to achieve this:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Dim Msg, Style, Title, Help, Ctxt, Response, MyString
Msg = "Have you filled in your LoginName on the first Sheet - (Jan)?
Please do so to save this file as Timesheet2005_YourLoginName "
Style = vbYesNo
Title = "Save Prompt"
Response = MsgBox(Msg, Style, Title)
If Response = vbYes Then
ThisWorkbook.SaveAs filename:=Sheets("Jan").Range("Y23")
Exit Sub
Else
Cancel = True
End If
End Sub
in a cell with their LoginName.
This LoginName will be used as the filename to save the file automatically.
But I am getting program error message followed by crashing of Excel.
Please help and advice. Also, can I automate the same process to save the
file in a specific folder?
Many thanks in advance.
Here is the code that I am using below to achieve this:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Dim Msg, Style, Title, Help, Ctxt, Response, MyString
Msg = "Have you filled in your LoginName on the first Sheet - (Jan)?
Please do so to save this file as Timesheet2005_YourLoginName "
Style = vbYesNo
Title = "Save Prompt"
Response = MsgBox(Msg, Style, Title)
If Response = vbYes Then
ThisWorkbook.SaveAs filename:=Sheets("Jan").Range("Y23")
Exit Sub
Else
Cancel = True
End If
End Sub