ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to hide "View Code" (https://www.excelbanter.com/excel-programming/432611-how-hide-view-code.html)

Dave[_11_]

How to hide "View Code"
 
Hi,
I am on Excel 2003.
I have a spreadsheet I am using the following property in a macro ,
the user can still view the "View Code" when they write click on a
tab. I would like that the "View Code" option be grayed out also along
with all the other options(which they are now)

ActiveWorkbook.Protect Password:="XXX", Structu=True

thanks in advance,

Dave

Don Guillett

How to hide "View Code"
 
Protect the macro project

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Dave" wrote in message
...
Hi,
I am on Excel 2003.
I have a spreadsheet I am using the following property in a macro ,
the user can still view the "View Code" when they write click on a
tab. I would like that the "View Code" option be grayed out also along
with all the other options(which they are now)

ActiveWorkbook.Protect Password:="XXX", Structu=True

thanks in advance,

Dave



JP Ronse

How to hide "View Code"
 
Hi Dave,

See the reply of Don, far the easiest way to do.

If you really want to disable the "View Code" ...

Application.CommandBars("Ply").Controls("&View Code").Enabled=False

to gray out, or
Application.CommandBars("Ply").Controls("&View Code").Visible=False

to hide.

With following code you will find the name of each commandbar and the
caption of all controls it has.
Sub test2()
Dim i As Integer
Dim j As Integer
For i = 1 To Application.CommandBars.Count
Debug.Print Application.CommandBars(i).Name
For j = 1 To Application.CommandBars(i).Controls.Count
Debug.Print , , , Application.CommandBars(i).Controls(j).Caption
Next
Next


End Sub

(Excel 2003)

Wkr,

JP


"Dave" wrote in message
...
Hi,
I am on Excel 2003.
I have a spreadsheet I am using the following property in a macro ,
the user can still view the "View Code" when they write click on a
tab. I would like that the "View Code" option be grayed out also along
with all the other options(which they are now)

ActiveWorkbook.Protect Password:="XXX", Structu=True

thanks in advance,

Dave




Rick Rothstein

How to hide "View Code"
 
If you really want to disable the "View Code" ...

Application.CommandBars("Ply").Controls("&View Code").Enabled=False

to gray out, or

Application.CommandBars("Ply").Controls("&View Code").Visible=False

to hide.


Of course, the OP should realize that executing either of those lines of
code won't stop the user from being able to press Alt+F11 or clicking
Tools/Macro/Visual Basic Editor.

--
Rick (MVP - Excel)



All times are GMT +1. The time now is 06:12 AM.

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