Results 1 to 8 of 8
  1. #1
    Star Lounger
    Join Date
    Mar 2001
    Posts
    85
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Customise toolbar using macro

    Using XL97 on NT4.51

    Because of NT I'm unable to change which buttons appear on my XL toolbars (well I can but everything defaults on reboot). I tried recording the customisation, but when I run the macro I get the following error msg: runtime error 2147467259 Method Add of Object 'Control Bar Controls Failed'. Looking in the debug window it shows that the code fails on the first line "Application.CommandBars("Standard").Controls. Add Type:=msoControlButton, Id _ :=755, Before:=24"

    Does anyone know if it's feasible to add toolbar buttons by running a macro like this, or are there any other approaches?

  2. #2
    5 Star Lounger
    Join Date
    Dec 2000
    Location
    Reading/Swindon, Berkshire, United Kingdom
    Posts
    664
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Customise toolbar using macro

    I would say the code should run but then I've never used nt. However, try changing ("standard") to (1)(this should make no difference in my opinion) and try changing Before:=24 to Before:=5 (I've never seen 24 items on the standard toolbar.) the id call seems valid (paste special if I guess right?) so I shouldn't worry about that. Try it - I really think it's the "before = 24" that's your problem.

    Brooke

  3. #3
    Star Lounger
    Join Date
    Mar 2001
    Posts
    85
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Customise toolbar using macro

    I've tried to do something simpler since, namely create a new toolbar on which to place any new buttons. The complete code recorded is:

    Application.CommandBars.Add(Name:="new").Visible = True
    Application.CommandBars("new").Controls.Add Type:=msoControlButton, Id:=442 _
    , Before:=1

    Then I deleted the new toolbar, and tried to run the macro.
    However it breaks down (on the second line). The error msg
    is runtime error 2147467259 (80004005) method "add" of object "commandbar controls" failed.

  4. #4
    5 Star Lounger
    Join Date
    Dec 2000
    Location
    Reading/Swindon, Berkshire, United Kingdom
    Posts
    664
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Customise toolbar using macro

    what happens if you run this code?

    Sub cormac9()

    Dim intCtrlPos As Integer
    Dim intCtrlPos2 As Integer

    intCtrlPos2 = 1

    On Error Resume Next

    With application
    With .CommandBars(1)
    intCtrlPos = .Controls.Count
    If intCtrlPos < 1 Then GoTo zero_jump
    Do Until .Controls(intCtrlPos2).Caption = "&Help" Or intCtrlPos2 >= intCtrlPos
    intCtrlPos2 = intCtrlPos2 + 1
    Loop
    intCtrlPos = intCtrlPos2
    zero_jump:

    With .Controls
    With .Add(msoControlPopup, , , intCtrlPos, True)
    .Caption = "&Brookestestfor cormac"
    With .Controls
    With .Add(msoControlPopup): .Caption = "&Information": With .Controls
    With .Add(msoControlButton): .Caption = "Application": .OnAction = "DisplayApplicationInfo": .FaceId = 263: End With
    End With: End With


    End With
    End With
    End With
    End With
    End With
    End Sub


    Brooke

  5. #5
    Star Lounger
    Join Date
    Mar 2001
    Posts
    85
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Customise toolbar using macro

    Don't know what it's supposed to do, but it doesn't seem to do anything. I pasted it into a vb module and tried to run it, but nothing- not even an error message. Probably me doing something wrong- I'm fairly out of my depth here.

  6. #6
    4 Star Lounger
    Join Date
    Jan 2001
    Location
    Kortrijk, Belgium
    Posts
    571
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Customise toolbar using macro

    Have a look at <A target="_blank" HREF=http://www.wopr.com/cgi-bin/w3t/showflat.pl?Cat=&Board=xl&Number=30032&page=2&view =expanded&sb=5> This thread </A>

  7. #7
    5 Star Lounger
    Join Date
    Dec 2000
    Location
    Reading/Swindon, Berkshire, United Kingdom
    Posts
    664
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Customise toolbar using macro

    You should have got a new menu item on the standard toolbar to the left of "help". Take a look at the link Hans has highlighted and let us know how you get on.

    Brooke

  8. #8
    Super Moderator WebGenii's Avatar
    Join Date
    Jan 2001
    Location
    Redcliff, Alberta, Canada
    Posts
    4,066
    Thanks
    2
    Thanked 5 Times in 5 Posts

    Re: Customise toolbar using macro

    Just a comment about the use of NT.
    I've seen your problem before - typically because of network administrators who don't understand using applications. So your installation of NT gets locked up to such an extent that you can't use your applications as intended. Anyhow, I don't know how big your company is or how your relationship with your technical support staff is - but I'd advise a chat with them. Because if these problems are occuring in Excel, I'll bet you will have similar difficulties in Word and PowerPoint.
    Just to clarify my statement - it isn't NT that is the problem - it is the way NT is being implemented.
    [b]Catharine Richardson (WebGenii)
    WebGenii Home Page
    Moderator: Spreadsheets, Other MS Apps, Presentation Apps, Visual Basic for Apps, Windows Mobile

Posting Permissions

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