Thread: Saving A File
View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
AA2e72E AA2e72E is offline
external usenet poster
 
Posts: 400
Default Saving A File

If the requestor name is the same as the computer's user name and the data is
today's, you can do this without input boxes. Try:

Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA"
(ByVal lpBuffer As String, nSize As Long) As Long

Sub SaveAs()
Dim UserName As String, FileName As String
UserName = String(100, Chr$(0))
GetUserName UserName, 100
UserName = Left$(UserName, InStr(UserName, Chr$(0)) - 1)
FileName = UserName & Format(Date, "mmddyy") & ".xls"
ActiveWorkbook.SaveAs FileName:=FileName
End Sub

NOTE: the filename should not exist already (you could consider using the
current time in the file name).

"CyndyG" wrote:

I am creating a template to be used to prompt for the following:
Enter RequestorName
Enter RequestDate in mmddyy format
Then have the file automatically save if possible,but use Save As since this
is a template.
So the file should appear like this within a folder: John Doe 041505

How would I code this?