Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Semiautomated Saving of workbook

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
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
Color Changes When Saving 2007 Workbook as 97 - 2003 Workbook Don Excel Discussion (Misc queries) 0 April 20th 08 04:51 AM
Saving a sheet in a workbook as .csv but not changing workbook name gloryofbach[_4_] Excel Programming 3 October 30th 05 08:50 PM
Saving workbook from VB Old Car Excel Programming 4 April 30th 05 07:24 AM
Saving a Workbook Dennis Excel Worksheet Functions 1 February 22nd 05 01:03 PM
Saving a Workbook: Forcing User to Rename before Saving Rollin_Again[_6_] Excel Programming 5 April 16th 04 02:54 PM


All times are GMT +1. The time now is 03:05 AM.

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

About Us

"It's about Microsoft Excel"