removing characters from a string variable...


Posted by rm on February 08, 2002 2:38 PM

hello,

How do you strip a character (the "&" symbol) out of a string?

Example:
Dim MenuCaption as String
MenuCaption = cbSubMenu.Caption

This returns the string "&New...", but I want vba to return string MenuCaption to be "New..." (without the "&").

Thanks for any help...rm

Posted by rm on February 08, 2002 2:46 PM

...or better yet...

...if someone knows a for next loop that will remove all menu items from CommandBars("Worksheet Menu Bar")...(example: "File" or "Edit" menu when clicked will have nothing listed in it.)

thanks...rm

Posted by Petruchio on February 08, 2002 3:57 PM

Re: ...or better yet...


To remove the menu bar :-
Application.CommandBars(1).Enabled = False
MenuBars.Add.Activate

To restore it :-
Application.CommandBars(1).Enabled = True
MenuBars(xlWorksheet).Activate

Posted by rm on February 08, 2002 5:29 PM

Re: ...or better yet...

Thank you Petruchio...

Do you know how to keep the menu bar, but remove the items in each menu command (example: "File" is visible, but no commands available within that menu?)

I want to keep the menu bar, but remove all of the menu items...thanks

rm

Posted by Petruchio on February 08, 2002 8:03 PM

Re: ...or better yet...


This will disable all the items on the worksheet menu bar :-

Sub Disable_WorksheetMenuBar()
Dim Mnu, MnuItem
On Error Resume Next
With CommandBars("Worksheet Menu Bar")
For Each Mnu In .Controls
For Each MnuItem In Mnu.Controls
MnuItem.Enabled = False
Next
Next
End With
End Sub

To restore, change False to True.

Posted by Petruchio on February 08, 2002 8:07 PM

OR .....

...... perhaps this is what you are looking for :-

Sub Disable_WorksheetMenuBar()
Dim Mnu
With CommandBars("Worksheet Menu Bar")
For Each Mnu In .Controls
Mnu.Enabled = False
Next
End With
End Sub




Posted by rm on February 08, 2002 8:11 PM

THANKS Petruchio...that's what I wanted!!