PDA

View Full Version : restore comannd bar .control



frsm
08-09-2007, 05:45 AM
hello all

i used this line


CommandBars("Worksheet menu bar").Controls("file").Delete

in workbook open code , that is delete the control file from the work book menue bar
i want another line to restore the command bar before close the workbook

thanks alot

Bob Phillips
08-09-2007, 05:46 AM
Use



CommandBars("Worksheet menu bar").Controls("file").Visible = False


and



CommandBars("Worksheet menu bar").Controls("file").Visible = True

frsm
08-09-2007, 06:20 AM
thanks alot XLD
i dnt want to use
CommandBars("Worksheet menu bar").Controls("file").Visible = False
i am using CommandBars("Worksheet menu bar").Controls("file").Delete
and i want the opposite line maybe it is
CommandBars("Worksheet menu bar").Controls("file").unDelete or anything else
thanks

Bob Phillips
08-09-2007, 06:42 AM
Why not?

frsm
08-09-2007, 06:46 AM
i want to try to restore the delted control (file) ;I tryed

CommandBars("Worksheet menu bar").Controls("file").reset
CommandBars("Worksheet menu bar").Controls("file").add
but i didnt work
P.S in the workbookopen() iam using CommandBars("Worksheet menu bar").Controls("file").delete.

rory
08-09-2007, 06:58 AM
1. It's much easier to use xld's code.
2. You could use commandbars(1).controls.Add id:=30002, before:=1

frsm
08-09-2007, 07:23 AM
thank you XLd

Bob Phillips
08-09-2007, 08:01 AM
You haven't told us why you would want to delete it and not just hide it.

frsm
08-09-2007, 08:06 AM
i think to delete it is more trusting for me ,i ensure that this control willnot be visible easily .i hide or delete the bars to secure the workbook from changing or reaching the vba editor . i have many ways to so that but everytime i find things is better and i want to try every thing thank you very much xld for your attention

Bob Phillips
08-09-2007, 08:09 AM
But if you can restore it via code, a user could restore it just as easily. So it is no more secure than just making it not visible.

Personally, I don't agree with hiding/deleting Excel controls. If you don't want to work in the Excel environment, then use something else.