LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
JTH JTH is offline
external usenet poster
 
Posts: 1
Default Workbook_BeforeSave Head ache

I am writing some VBA code for an excel spreadsheet that includes a button on
the sheet that forces a SaveAs with a incremental version # and such. That
all works great.

Now I want to prevent the user from saving from the tool bar or file menu. I
wanted the Button Click value to be visible from the €śWorkbook_BeforeSave€ť
sub but it seems that my variables are not that public€¦.. Ideas? If I could
get values into the Workbook_BeforeSave sub it would be a €śNo Brainer€ť



Dim Today As Date
Dim DateText As Double
Dim FileText As String
Dim Final As String
Dim Rev As Single
Dim ProjName As String
Dim FileNameAndLocal As Variant
Public BttnClick As Boolean

Public Sub CommandButton1_Click()
BttnClick = True
RenameNRev
SaveAsWhatEver

End Sub


Public Sub RenameNRev()

Worksheets("InstrumentIndex").Activate

Range("d2").Select

FileText = ActiveCell & "_"


Today = Date + Time
DateText = Today


Range("k2").Select
Rev = ActiveCell
Rev = Rev + 0.1
ActiveCell = Rev
Range("k3").Select
ActiveCell = Today
Rev = Round(Rev, 1)
Final = FileText & Rev & ".xls"


End Sub


Public Sub SaveAsWhatEver()
FileNameAndLocal = Application.GetSaveAsFilename(Final)

If FileNameAndLocal = False Then
MsgBox "The file was not saved", vbCritical, "The file was not saved"
End If

If BttnClick = True Then
If FileNameAndLocal = False Then
Range("k2").Select
Rev = ActiveCell
Rev = Rev - 0.1
ActiveCell = Rev
Else
ActiveWorkbook.SaveAs (FileNameAndLocal), FileFormat:=xlNormal

End If
End If

End Sub

 
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
HELP!!!! Calling a sub from Workbook_BeforeSave RocketMan[_2_] Excel Discussion (Misc queries) 4 May 31st 07 11:47 PM
Workbook_BeforeSave() bmm Excel Programming 3 August 16th 04 03:37 PM
Workbook_Beforesave getting breached Hari[_3_] Excel Programming 2 June 11th 04 10:57 PM
Workbook_BeforeSave Bill Oertell Excel Programming 5 December 21st 03 07:33 PM
Workbook_BeforeSave() in xla Bent Kjeldsen Excel Programming 6 September 24th 03 01:49 PM


All times are GMT +1. The time now is 05:54 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"