Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 72
Default Disable Save on Tool Bar?

Is it possible to disable and hide the save button from the tool bar as well
as disable Ctrl + S and Save As?

I want the command button I have built to be the only method available to
save the file.

Thanks for any suggestions.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Disable Save on Tool Bar?

You could customize toolbars to remove those menus and assign shortcut
Ctrl-S to your own macro.

Another approach might be to trap the save event at application level in
your main workbook or an addin and process, eg

' in a Class1 change name later to say clsApp
Public WithEvents xlApp As Excel.Application

Private Sub xlApp_WorkbookBeforeSave(ByVal Wb As Workbook, _
ByVal SaveAsUI As Boolean, Cancel As Boolean)
Dim ws As Worksheet
On Error GoTo errH

'perhaps first some test if Wb properties are relevant

Set ws = Wb.Worksheets("Sheet1")
' will error & run to errH if no Sheet1

If ws.Range("A1") = 111 Then
'do nothing, normal save will occur
ElseIf ws.Range("A1") = 222 Then
'stop normal save
'change 222 333 and save
'prevent events running while changing cell
' & doing own save
Cancel = True
xlApp.EnableEvents = False
ws.Range("A1") = 333
Wb.Save
Else
Cancel = True ' stop the save
MsgBox "Sheet1:A1 wrong", , "Save cancelled"
End If

errH:
xlApp.EnableEvents = True
End Sub

' in a normal module
Dim clAppEvents As Class1

Sub auto_open()
'manually run to test

Set clAppEvents = New Class1
Set clAppEvents.xlApp = Application
End Sub

Regards,
Peter T


"TimN" wrote in message
...
Is it possible to disable and hide the save button from the tool bar as

well
as disable Ctrl + S and Save As?

I want the command button I have built to be the only method available to
save the file.

Thanks for any suggestions.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Disable Save on Tool Bar?

Just to add,

if this functionality is for only one workbook, you can just use the
workbook level beforesave event.

--
Regards,
Tom Ogilvy


"Peter T" wrote:

You could customize toolbars to remove those menus and assign shortcut
Ctrl-S to your own macro.

Another approach might be to trap the save event at application level in
your main workbook or an addin and process, eg

' in a Class1 change name later to say clsApp
Public WithEvents xlApp As Excel.Application

Private Sub xlApp_WorkbookBeforeSave(ByVal Wb As Workbook, _
ByVal SaveAsUI As Boolean, Cancel As Boolean)
Dim ws As Worksheet
On Error GoTo errH

'perhaps first some test if Wb properties are relevant

Set ws = Wb.Worksheets("Sheet1")
' will error & run to errH if no Sheet1

If ws.Range("A1") = 111 Then
'do nothing, normal save will occur
ElseIf ws.Range("A1") = 222 Then
'stop normal save
'change 222 333 and save
'prevent events running while changing cell
' & doing own save
Cancel = True
xlApp.EnableEvents = False
ws.Range("A1") = 333
Wb.Save
Else
Cancel = True ' stop the save
MsgBox "Sheet1:A1 wrong", , "Save cancelled"
End If

errH:
xlApp.EnableEvents = True
End Sub

' in a normal module
Dim clAppEvents As Class1

Sub auto_open()
'manually run to test

Set clAppEvents = New Class1
Set clAppEvents.xlApp = Application
End Sub

Regards,
Peter T


"TimN" wrote in message
...
Is it possible to disable and hide the save button from the tool bar as

well
as disable Ctrl + S and Save As?

I want the command button I have built to be the only method available to
save the file.

Thanks for any suggestions.




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 72
Default Disable Save on Tool Bar?

Could you expand further on that thought?
This is for one workbook that will be distributed to several users.

"Tom Ogilvy" wrote:

Just to add,

if this functionality is for only one workbook, you can just use the
workbook level beforesave event.

--
Regards,
Tom Ogilvy


"Peter T" wrote:

You could customize toolbars to remove those menus and assign shortcut
Ctrl-S to your own macro.

Another approach might be to trap the save event at application level in
your main workbook or an addin and process, eg

' in a Class1 change name later to say clsApp
Public WithEvents xlApp As Excel.Application

Private Sub xlApp_WorkbookBeforeSave(ByVal Wb As Workbook, _
ByVal SaveAsUI As Boolean, Cancel As Boolean)
Dim ws As Worksheet
On Error GoTo errH

'perhaps first some test if Wb properties are relevant

Set ws = Wb.Worksheets("Sheet1")
' will error & run to errH if no Sheet1

If ws.Range("A1") = 111 Then
'do nothing, normal save will occur
ElseIf ws.Range("A1") = 222 Then
'stop normal save
'change 222 333 and save
'prevent events running while changing cell
' & doing own save
Cancel = True
xlApp.EnableEvents = False
ws.Range("A1") = 333
Wb.Save
Else
Cancel = True ' stop the save
MsgBox "Sheet1:A1 wrong", , "Save cancelled"
End If

errH:
xlApp.EnableEvents = True
End Sub

' in a normal module
Dim clAppEvents As Class1

Sub auto_open()
'manually run to test

Set clAppEvents = New Class1
Set clAppEvents.xlApp = Application
End Sub

Regards,
Peter T


"TimN" wrote in message
...
Is it possible to disable and hide the save button from the tool bar as

well
as disable Ctrl + S and Save As?

I want the command button I have built to be the only method available to
save the file.

Thanks for any suggestions.




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 72
Default Disable Save on Tool Bar?

Tom,

After being pointed in this direction (Beforesave event) I found how to make
it work. Thanks! Now on to the next problem.

Tim

"Tom Ogilvy" wrote:

Just to add,

if this functionality is for only one workbook, you can just use the
workbook level beforesave event.

--
Regards,
Tom Ogilvy


"Peter T" wrote:

You could customize toolbars to remove those menus and assign shortcut
Ctrl-S to your own macro.

Another approach might be to trap the save event at application level in
your main workbook or an addin and process, eg

' in a Class1 change name later to say clsApp
Public WithEvents xlApp As Excel.Application

Private Sub xlApp_WorkbookBeforeSave(ByVal Wb As Workbook, _
ByVal SaveAsUI As Boolean, Cancel As Boolean)
Dim ws As Worksheet
On Error GoTo errH

'perhaps first some test if Wb properties are relevant

Set ws = Wb.Worksheets("Sheet1")
' will error & run to errH if no Sheet1

If ws.Range("A1") = 111 Then
'do nothing, normal save will occur
ElseIf ws.Range("A1") = 222 Then
'stop normal save
'change 222 333 and save
'prevent events running while changing cell
' & doing own save
Cancel = True
xlApp.EnableEvents = False
ws.Range("A1") = 333
Wb.Save
Else
Cancel = True ' stop the save
MsgBox "Sheet1:A1 wrong", , "Save cancelled"
End If

errH:
xlApp.EnableEvents = True
End Sub

' in a normal module
Dim clAppEvents As Class1

Sub auto_open()
'manually run to test

Set clAppEvents = New Class1
Set clAppEvents.xlApp = Application
End Sub

Regards,
Peter T


"TimN" wrote in message
...
Is it possible to disable and hide the save button from the tool bar as

well
as disable Ctrl + S and Save As?

I want the command button I have built to be the only method available to
save the file.

Thanks for any suggestions.




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
disable Tool menu Sameh Farouk Excel Programming 2 April 18th 06 12:49 PM
Enable and Disable Tool Bar parteegolfer Excel Programming 0 March 16th 06 09:03 PM
Hide/Disable Tool bar ExcelMonkey Excel Programming 1 February 5th 06 12:46 AM
Disable Editing tool bars Mike Rogers Excel Discussion (Misc queries) 8 December 9th 05 09:22 PM
Disable Customize option next to a tool bar from VB ourspt Excel Discussion (Misc queries) 1 October 24th 05 12:04 PM


All times are GMT +1. The time now is 11:42 PM.

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

About Us

"It's about Microsoft Excel"