Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
SU SU is offline
external usenet poster
 
Posts: 25
Default Prompt message and Automated saving!

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Prompt message and Automated saving!

why not just get the information yourself:


See mr Erlandsen's page
http://www.erlandsendata.no/english/index.php?t=envbaos
or Chris Rae's page http://www.chrisrae.com/vba/routines.html

or use the environment variable:

[demo'd from the immediate window]
sstr = environ("Username")
? sStr
OgilvyTW

--
Regards,
Tom Ogilvy

"SU" wrote in message
...
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



  #3   Report Post  
Posted to microsoft.public.excel.programming
SU SU is offline
external usenet poster
 
Posts: 25
Default Prompt message and Automated saving!

Tom
Tried both sites. Could not find the required information. Please Help.

"Tom Ogilvy" wrote:

why not just get the information yourself:


See mr Erlandsen's page
http://www.erlandsendata.no/english/index.php?t=envbaos
or Chris Rae's page http://www.chrisrae.com/vba/routines.html

or use the environment variable:

[demo'd from the immediate window]
sstr = environ("Username")
? sStr
OgilvyTW

--
Regards,
Tom Ogilvy

"SU" wrote in message
...
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




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default Prompt message and Automated saving!

Why prompt the user?
Tom's suggestion to grab it out of the environment means less keystrokes for
the user and no false key stokes. If you need it stored in a cell, you can
do this with code as well. The user will have no option. The information
will be accurate.

Alternatively, if you must prompt the user why make them stop, navigate to a
sheet, write some information then save again:

if isblank(Sheets("Jan").Range("Y23")) then
curUser= inputbox "What is your Login Name?" ' look up inputbox in help
for the rest
Sheets("Jan").Range("Y23")) = curUser
end if




"SU" wrote in message
...
Tom
Tried both sites. Could not find the required information. Please Help.

"Tom Ogilvy" wrote:

why not just get the information yourself:


See mr Erlandsen's page
http://www.erlandsendata.no/english/index.php?t=envbaos
or Chris Rae's page http://www.chrisrae.com/vba/routines.html

or use the environment variable:

[demo'd from the immediate window]
sstr = environ("Username")
? sStr
OgilvyTW

--
Regards,
Tom Ogilvy

"SU" wrote in message
...
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






Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
help with message prompt Monty New Users to Excel 1 September 9th 05 10:03 AM
how to disable save prompt on closing excel file in automated mode [email protected] Excel Discussion (Misc queries) 3 July 6th 05 10:35 PM
Message prompt in VBA ltong Excel Programming 4 October 6th 04 05:16 PM
Prompt before saving cskgg[_4_] Excel Programming 2 August 13th 04 02:17 AM
Prompt before saving cskgg[_3_] Excel Programming 2 August 10th 04 01:15 PM


All times are GMT +1. The time now is 10:51 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"