auto save?

  • Thread starter Thread starter -Brian-H-
  • Start date Start date
B

-Brian-H-

I'd like to have a "save" button (or any other method) on my form whic
automaticly saves the work book to the server and names the saved fil
using info from 2 cells on the first sheet. ex... name cell and dat
cell...GWOLF2304. there are roughly 25 users using this workboo
 
Brian,

Right-click on any worksheet tab abd click on View Code. This will take you
to the VB editor. On the left hand side (project explorer) click on the bold
node reading VBAProject(YourWorkbookName) to select it and go to menu Insert
Module. You will see a new node Module1 under your VBA project, and the
cursor will now be in the VB editor window (top right hand side). Paste the
following code in there:

Sub Save_As_FileName()
Usr = Range("A1").Value
Dte = Range("A2").Value
Pth = "K:\MyFolder\MySubFolder\"
ActiveWorkbook.SaveAs Filename:= Pth & Usr & Dte & ".xls", _
FileFormat:=xlNormal, Password:="", WriteResPassword:="",
ReadOnlyRecommended:=False, _
CreateBackup:=False
End Sub

Change the cell references in the code to the real ones, and the path
likewise. Also, if you want you can change the date line to:
Dte = Format(Range("A2").Value,"ddmmyy")
(or whatever format you want) to predetermine the date part format,
regardless of users' Windows settings (recommended).

Save and close the VB window. So far you have created the macro that does
the job. Now all that's left to do is to create the button and assign it
that macro.

HTH,
Nikos
 
You got hit by a linewrap problem.

Sub Save_As_FileName()
Usr = Range("A1").Value
Dte = Range("A2").Value
Pth = "K:\MyFolder\MySubFolder\"
ActiveWorkbook.SaveAs Filename:= Pth & Usr & Dte & ".xls", _
FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
End Sub

The ReadOnlyRecommended could have been moved up to the previous line, too.
 
Back
Top