![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
New Member
Join Date: Feb 2002
Posts: 8
|
I am looking for a solution that will save a file with data from within the spreadsheet when a user selects "file", "save". I want it to take data from "a1,b1,c1" and save the file with the filename such as "username - date - score" like (mccolk - 022302 - 95) and save it to a specified folder (g:coaching databasemccolk - 022302 -95.xls). If anyone has any suggestions or examples, it would be greatly appreciated. Thanks in advance
|
|
|
|
|
|
#2 |
|
Board Regular
Join Date: Mar 2002
Posts: 60
|
Kevin
Try modifying this for your needs: sub saveme() ActiveWorkbook.SaveAs Filename:="C:Documents and SettingsdefaultMy Documentsscores " & _ ' Format(Sheets("Store Info").Range("d4"), "0 ") & _ ' Format(Sheets("Store Info").Range("h2"), _ ' "yy.mmdd") & ".xls" end sub The above will save a file in the name of Scores+"D4"+"H2(in date format)" in my documents HTH Dan. |
|
|
|
|
|
#3 |
|
Board Regular
Join Date: Mar 2002
Posts: 363
|
Here's a solution that will work with the save button on the toolbar and from File > Save on the menu bar.
Dim btnSave1 As CommandBarButton Dim btnSave2 As CommandBarButton Sub Auto_Open() Set btnSave1 = CommandBars("Standard").Controls("Save") Set btnSave2 = CommandBars("File").Controls("Save") With btnSave1 .Visible = True .OnAction = "CustomSave" End With With btnSave2 .OnAction = "CustomSave" End With End Sub Sub CustomSave() Dim SaveName As String Dim Dir As String MsgBox "hi" Application.DisplayAlerts = False Dir = "C:My Documents" SaveName = Cells(1, 1) & "-" & Cells(1, 2) & "-" & Cells(1, 3) SaveName = Dir & SaveName ActiveWorkbook.SaveAs Filename:=SaveName End Sub Sub Auto_Close() CommandBars("Standard").Controls("Save").Reset CommandBars("File").Controls("Save").Reset End Sub |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|