Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
First, I don't think I'd put assign this code to a toolbar icon.
That icon could be used for any workbook. Instead, I'd drop a button from the Forms toolbar (not the control toolbox toolbar) on that sheet that gets the username and sunDT entries. Then I'd assign this macro to that button: Option Explicit Sub SaveWorkbook() Dim USRNM As String Dim SunDT As String Dim strFName As String With ActiveSheet USRNM = .Range("b5").Value SunDT = .Range("A11").Value If Trim(USRNM) = "" _ Or Trim(SunDT) = "" Then MsgBox "Please fill in the username and Sunday Date" & vbLf _ & "File not saved!" Else strFName = "TimeCard " & SunDT & " " & USRNM .Parent.SaveAs strFName End If End With End Sub And if that SunDt is really a date, remember that if you're using Windows, then the filename cannot include slashes (like in 01/15/2007). Maybe... SunDT = format(.Range("A11").Value, "yyyy_mm_dd") instead????? DawnTreader wrote: Hello i am currently working to "dummy" proof a spreadsheet. i want my users to be able to hit a button and save the workbook, but not have to type a name in the dialog. i still want them to be able to save the workbook where ever they like, but i dont want them to be able to type in the name. how? here is my code so far: Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) Dim wb As Workbook Set wb = ActiveWorkbook Dim USRNM As String USRNM = Range("b5").Value Dim SunDT As String SunDT = Range("A11").Value Dim strFName As String strFName = "TimeCard " & SunDT & " " & USRNM ' Save file wb.SaveAs strFName End Sub additionally how do i connect this to a button on my toolbar? -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Color Changes When Saving 2007 Workbook as 97 - 2003 Workbook | Excel Discussion (Misc queries) | |||
Saving a sheet in a workbook as .csv but not changing workbook name | Excel Programming | |||
Saving workbook from VB | Excel Programming | |||
Saving a Workbook | Excel Worksheet Functions | |||
Saving a Workbook: Forcing User to Rename before Saving | Excel Programming |