Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 504
Default Permanently prevent User to see Formula Bar

Could be another difference between 2003 and 2007. After running this code
in 03 the Formula Bar option is not visible in the View menu. Have your
confirmed that the caption is indeed "&Formula Bar"

"OMER" wrote:

Thnak you Kevin.
I included this code and it actually hides the formula bar.
There is a big BUT though. The user can still go to the View menu and
activate it back, overrinding the command.

There should be a way to actually prevent the user to override this setting
while the workbook is open, but can't find it yet.

Regards,
Oscar

PS. This command has a similar effect on the formula Bar, but again, the
user can still modify it.

Application.DisplayFormulaBar = False


"Kevin" wrote:

Better yet, just run the following. No need to determine control ID numbers.

Sub DisableFormulaBar()
Dim cbCtlCtl As CommandBarControl
Dim cbCtl As CommandBarControl
Dim cbBar As CommandBar
Application.DisplayFormulaBar = False
For Each cbBar In CommandBars
If cbBar.Name = "Worksheet Menu Bar" Then
For Each cbCtl In cbBar.Controls
If cbCtl.Caption = "&View" Then
For Each cbCtlCtl In cbCtl.Controls
If cbCtlCtl.Caption = "&Formula Bar" Then
cbCtlCtl.Visible = False
Next
End If
Next cbCtl
End If
Next cbBar
End Sub

"Kevin" wrote:

Try this. Use the following code to determine the ID numbers associated with
the View and FormulaBar controls.

Sub List_cbCtlCtl()
Dim cbCtlCtl As CommandBarControl
Dim cbCtl As CommandBarControl
Dim cbBar As CommandBar
Dim i As Integer
i = 1
For Each cbBar In CommandBars
If cbBar.Name = "Worksheet Menu Bar" Then
For Each cbCtl In cbBar.Controls
If cbCtl.Type = 10 Then 'msoControlPopup control type
For Each cbCtlCtl In cbCtl.Controls
Cells(i, 1) = cbBar.Name
Cells(i, 2) = cbCtl.Caption
Cells(i, 3) = cbCtl.ID
Cells(i, 4) = cbCtlCtl.Caption
Cells(i, 5) = cbCtlCtl.ID
i = i + 1
Next
End If
Next cbCtl
End If
Next cbBar
Range("A:E").EntireColumn.AutoFit
End Sub

Find the View ID number in column C. Find the FormulaBar ID number in
column E. Substitute these numbers in the following code.

Sub Disable_cbCtlCtl()
Dim cbCtlCtl As CommandBarControl
Dim cbCtl As CommandBarControl
Dim cbBar As CommandBar
Application.DisplayFormulaBar = False
For Each cbBar In CommandBars
If cbBar.Name = "Worksheet Menu Bar" Then
For Each cbCtl In cbBar.Controls
If cbCtl.ID = <place View ID number here Then
For Each cbCtlCtl In cbCtl.Controls
If cbCtlCtl.ID = <place FormulaBar ID number here
Then
cbCtlCtl.Enabled = False
cbCtlCtl.Visible = False
End If
Next
End If
Next cbCtl
End If
Next cbBar
End Sub

"OMER" wrote:

That is it.

I'm using Excel 2007, any ideas for that version?

Regards,
OMER

"Kevin" wrote:

Could it be different versions. I'm using Excel 2003.

I got the following:

Col A Col B Col C
Worksheet Menu Bar 30002 &File
30003 &Edit
30004 &View
30005 &Insert
30006 F&ormat
30007 &Tools
30011 &Data
30083 A&ction
1 Show&Case
30009 &Window
30010 &Help
1 Ado&be PDF

From the code:

Sub ListCBcontrols()
Dim CBctrl As CommandBarControl, RowNum As Integer
RowNum = 1
For Each CBctrl In Application.CommandBars.Item(1).Controls
Cells(1, 1) = Application.CommandBars.Item(1).Name
Cells(RowNum, 2) = CBctrl.ID
Cells(RowNum, 3) = CBctrl.Caption
RowNum = RowNum + 1
Next
End Sub

"OMER" wrote:

Hola Kevin, thanks for your prompt response.

I tried your solution and it didn't hide any of the options in the View menu.
It did hide options in the Home, Insert, and Data menu options. The other
options remain open for the user to modify them.

This is what I entered:

Sub HideCBcontrols()
'
' Hide Formula Bar preventing user to activate it back
'
Dim CB As CommandBar, CBctrl As CommandBarControl
Dim CBnum As Integer, CBname As String
Dim CBctrlNum As Integer
CBnum = 1
CBctrlNum = 30004
On Error Resume Next
For Each CBctrl In Application.CommandBars.Item(CBnum).Controls
If CBctrl.ID = CBctrlNum Then
CBctrl.Visible = False
End If
Next
End Sub

Am I missing something?
OMER


"Kevin" wrote:

You could hide the View CommandBarControl in the Worksheet Main Menu. Use
the following code and set CBnum = 1 and CBctrl = 30004. Use the second set
of code to unhide it.

Hope this helps.

Sub HideCBcontrols()
Dim CB As CommandBar, CBctrl As CommandBarControl
Dim CBnum As Integer, CBname As String
Dim CBctrlNum As Integer
CBnum = InputBox("Enter CommandBar Index No.")
CBctrlNum = InputBox("Enter CommandBarCtrl ID No.")
On Error Resume Next
For Each CBctrl In Application.CommandBars.Item(CBnum).Controls
If CBctrl.ID = CBctrlNum Then
CBctrl.Visible = False
End If
Next
End Sub

Sub ShowCBcontrols()
Dim CB As CommandBar, CBctrl As CommandBarControl
Dim CBnum As Integer, CBname As String
Dim CBctrlNum As Integer
CBnum = InputBox("Enter CommandBar Index No.")
CBctrlNum = InputBox("Enter CommandBarCtrl ID No.")
On Error Resume Next
For Each CBctrl In Application.CommandBars.Item(CBnum).Controls
If CBctrl.ID = CBctrlNum Then
CBctrl.Visible = True
End If
Next
End Sub

"OMER" wrote:

Hola,
I wonder if there is a way to prevent (permanently) a user to activate the
formula bar while a specific worbook is open. I'm able to hide it inside the
openning macro with the following command:

Application.DisplayFormulaBar = False

However, the user can still go to the ribon menu and activate it back.
I want it top remain hidden until the workbook is closed.

Thank you for your help.
OMER

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
Prevent Tab from User Delete Ardy Excel Worksheet Functions 2 September 9th 09 02:38 PM
Prevent user from using Name Matlock Excel Discussion (Misc queries) 5 March 13th 08 04:58 AM
Prevent user moving to next control johncassell[_11_] Excel Programming 7 July 31st 05 08:12 PM
Prevent User from saving crapit Excel Programming 2 July 26th 04 03:48 PM
How do I: prevent user from scolling down and right? jasonsweeney[_39_] Excel Programming 3 February 5th 04 07:06 PM


All times are GMT +1. The time now is 04:16 PM.

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"