Can we disable Excel's default toolbar?

  • Thread starter Thread starter JK
  • Start date Start date
J

JK

My application deletes Excel's toolbar and creates my toolbar. However,
Excel (at least with 2003) retains one icon on my tool bar to the immediate
left that allows the user several options I don't want the user to select.

Is it possible, when creating my toobar, to disable this Excel icon and/or
selections?

Thank you in advance.

Jim Kobzeff
 
JK said:
My application deletes Excel's toolbar and creates my toolbar. However,
Excel (at least with 2003) retains one icon on my tool bar to the immediate
left that allows the user several options I don't want the user to select.

Is it possible, when creating my toobar, to disable this Excel icon and/or
selections?

Hi Jim,

This icon can be removed by protecting your workbook. It's the Windows
protection option that does the trick. It doesn't matter whether or not you
protect the Structure.

--
Rob Bovey, MCSE, MCSD, Excel MVP
Application Professionals
http://www.appspro.com/

* Please post all replies to this newsgroup *
* I delete all unsolicited e-mail responses *
 
Thank you, Rob. I did as you suggested, but it didn't work. The Excel icon
and its menu selections remain alive and well.

Jim Kobzeff
 
Hi Jim,

Are you sure you're talking about the Excel icon located on the toolbar
or the Excel icon located in the top left corner of the screen? There are
two located roughly one above the other. Protecting the workbook using the
Tools/Protection/Protect Workbook menu and making sure the Windows checkbox
is selected will definitely remove the icon associated with the menu bar.
The Application window icon cannot be removed, but you can disable and
restore it with API calls as shown below:

Private Const MF_BYCOMMAND As Long = &H0
Private Const SC_CLOSE As Long = &HF060
Private Const API_FALSE As Long = 0&
Private Const API_TRUE As Long = 1&

Private Declare Function FindWindowA Lib "user32" ( _
ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
Private Declare Function GetSystemMenu Lib "user32" ( _
ByVal hWnd As Long, _
ByVal bRevert As Long) As Long
Private Declare Function DeleteMenu Lib "user32" ( _
ByVal hMenu As Long, _
ByVal nPosition As Long, _
ByVal wFlags As Long) As Long
Private Declare Function DrawMenuBar Lib "user32" ( _
ByVal hWnd As Long) As Long

Private Sub DeleteXCloseMenu()
Dim hWnd As Long
hWnd = FindWindowA(vbNullString, Application.Caption)
DeleteMenu GetSystemMenu(hWnd, API_FALSE), SC_CLOSE, MF_BYCOMMAND
DrawMenuBar hWnd
End Sub

Private Sub RestoreXCloseMenu()
Dim hWnd As Long
hWnd = FindWindowA(vbNullString, Application.Caption)
GetSystemMenu hWnd, API_TRUE
End Sub

--
Rob Bovey, MCSE, MCSD, Excel MVP
Application Professionals
http://www.appspro.com/

* Please post all replies to this newsgroup *
* I delete all unsolicited e-mail responses *
 
Thank you, Rob. That did it.

Jim Kobzeff
Rob Bovey said:
Hi Jim,

Are you sure you're talking about the Excel icon located on the toolbar
or the Excel icon located in the top left corner of the screen? There are
two located roughly one above the other. Protecting the workbook using the
Tools/Protection/Protect Workbook menu and making sure the Windows
checkbox
is selected will definitely remove the icon associated with the menu bar.
The Application window icon cannot be removed, but you can disable and
restore it with API calls as shown below:

Private Const MF_BYCOMMAND As Long = &H0
Private Const SC_CLOSE As Long = &HF060
Private Const API_FALSE As Long = 0&
Private Const API_TRUE As Long = 1&

Private Declare Function FindWindowA Lib "user32" ( _
ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
Private Declare Function GetSystemMenu Lib "user32" ( _
ByVal hWnd As Long, _
ByVal bRevert As Long) As Long
Private Declare Function DeleteMenu Lib "user32" ( _
ByVal hMenu As Long, _
ByVal nPosition As Long, _
ByVal wFlags As Long) As Long
Private Declare Function DrawMenuBar Lib "user32" ( _
ByVal hWnd As Long) As Long

Private Sub DeleteXCloseMenu()
Dim hWnd As Long
hWnd = FindWindowA(vbNullString, Application.Caption)
DeleteMenu GetSystemMenu(hWnd, API_FALSE), SC_CLOSE, MF_BYCOMMAND
DrawMenuBar hWnd
End Sub

Private Sub RestoreXCloseMenu()
Dim hWnd As Long
hWnd = FindWindowA(vbNullString, Application.Caption)
GetSystemMenu hWnd, API_TRUE
End Sub

--
Rob Bovey, MCSE, MCSD, Excel MVP
Application Professionals
http://www.appspro.com/

* Please post all replies to this newsgroup *
* I delete all unsolicited e-mail responses *
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top