Consulting

Results 1 to 10 of 10

Thread: restore comannd bar .control

  1. #1
    VBAX Regular
    Joined
    Jul 2007
    Posts
    15
    Location

    restore comannd bar .control

    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

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Use

    [vba]

    CommandBars("Worksheet menu bar").Controls("file").Visible = False
    [/vba]

    and

    [vba]

    CommandBars("Worksheet menu bar").Controls("file").Visible = True
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    VBAX Regular
    Joined
    Jul 2007
    Posts
    15
    Location
    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

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Why not?
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  5. #5
    VBAX Regular
    Joined
    Jul 2007
    Posts
    15
    Location
    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.

  6. #6
    VBAX Master
    Joined
    Jun 2007
    Location
    East Sussex
    Posts
    1,110
    Location
    1. It's much easier to use xld's code.
    2. You could use commandbars(1).controls.Add id:=30002, before:=1
    Regards,
    Rory

    Microsoft MVP - Excel

  7. #7
    VBAX Regular
    Joined
    Jul 2007
    Posts
    15
    Location
    thank you XLd

  8. #8
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    You haven't told us why you would want to delete it and not just hide it.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  9. #9
    VBAX Regular
    Joined
    Jul 2007
    Posts
    15
    Location
    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

  10. #10
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    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.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •