ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   What am I doing wrong? (https://www.excelbanter.com/excel-programming/376687-what-am-i-doing-wrong.html)

TimN

What am I doing wrong?
 
I have the following code that will disable the File \ Save As function on
the tool bar:
Private Sub Workbook_Activate()
Application.CommandBars("Worksheet Menu Bar").FindControl _
(ID:=748, Recursive:=True).Enabled = False
End Sub

The problem is when I close this workbook and open a different one, my File
\ Save As is disabled there also. I thought the VBA code would only impact
the workbook in which it was written. What am I missing?

Bob Umlas, Excel MVP

What am I doing wrong?
 
Nothing. Commandbars are en Excel setting, not a workbook setting. You need
to restore the functionality. Maybe just put the Enabled back to true on the
Workbook_BeforeClose event.

"TimN" wrote:

I have the following code that will disable the File \ Save As function on
the tool bar:
Private Sub Workbook_Activate()
Application.CommandBars("Worksheet Menu Bar").FindControl _
(ID:=748, Recursive:=True).Enabled = False
End Sub

The problem is when I close this workbook and open a different one, my File
\ Save As is disabled there also. I thought the VBA code would only impact
the workbook in which it was written. What am I missing?


Tom Ogilvy

What am I doing wrong?
 
No. Changes to menus/commandbars are application changes.

--
Regards,
Tom Ogilvy


"TimN" wrote:

I have the following code that will disable the File \ Save As function on
the tool bar:
Private Sub Workbook_Activate()
Application.CommandBars("Worksheet Menu Bar").FindControl _
(ID:=748, Recursive:=True).Enabled = False
End Sub

The problem is when I close this workbook and open a different one, my File
\ Save As is disabled there also. I thought the VBA code would only impact
the workbook in which it was written. What am I missing?



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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com