Consulting

Results 1 to 16 of 16

Thread: Ribbon Issue

  1. #1
    VBAX Mentor
    Joined
    Jan 2006
    Posts
    323
    Location

    Ribbon Issue

    I created a custom group on the ribbon that is associated with some macros. I only want this group to be in a certain file but it is now permanent. Does anyone know how do I make it so the group on the ribbon I created only shows and works from a specific file? It occurs in both excel 2010 and 2013.

  2. #2
    VBAX Guru mancubus's Avatar
    Joined
    Dec 2010
    Location
    "Where I lay my head is home" :D
    Posts
    2,644
    http://www.rondebruin.nl/win/s2/win002.htm

    check the examples linked at the bottom of the page.
    PLS DO NOT PM; OPEN A THREAD INSTEAD!!!

    1) Posting Code
    [CODE]PasteYourCodeHere[/CODE]
    (or paste your code, select it, click # button)

    2) Uploading File(s)
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) (multiple files can be selected while holding Ctrl key) / Upload Files / Done
    Replace company specific / sensitive / confidential data. Include so many rows and sheets etc in the uploaded workbook to enable the helpers visualize the data and table structure. Helpers do not need the entire workbook.

    3) Testing the Codes
    always back up your files before testing the codes.

    4) Marking the Thread as Solved
    from Thread Tools (on the top right corner, above the first message)

  3. #3
    VBAX Mentor
    Joined
    Jan 2006
    Posts
    323
    Location
    Thanks for the reply. Unfortunately I am working on a network where I don't have permission to download the UI editor. Was much easier in Excel 2003 in the open and close events.

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Excel files are just zipped files, so you could create a file called customUI.xml with the appropriate xml in it, put that in a folder called customUI. Then change your Excel workbook file extension to .zip, open it with a Zip file editor, and drop that customUI into the zipped file, then rename it back. Convoluted, but should work if you can't get hold of the editor.
    ____________________________________________
    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 Mentor
    Joined
    Jan 2006
    Posts
    323
    Location
    Thanks XLD but it sounds like more or a hassle than need be. I have Excel 2007 on my personal computer and I will download the UI to it and work from there.

  6. #6
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    It is, a lot more, but if you don't have a screwdriver you have to use the hammer.
    ____________________________________________
    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

  7. #7
    VBAX Mentor
    Joined
    Jan 2006
    Posts
    323
    Location
    Thank you both for your assistance. I was able to avoid using the "hammer" by using the editor on my home computer in Excel 2007 and it works on my work computer in Excel 2013.
    *Solved*

    Gary

  8. #8
    VBAX Mentor
    Joined
    Jan 2006
    Posts
    323
    Location
    I marked it solved too soon. After using the editor and adding (control As IRibbonControl) to the appropriate sub header things work great on the ribbon. However, I found out that when other subs call one of the subs with the (control As IRibbonControl) it pops a compile error - "Argument not Optional". Adding (control As IRibbonControl) to the sub call that fails then gives a compile error - "Expected: list separator or )".
    Is there a way to call this sub from another routine?
    Or can it now only be used from the ribbon and I have to duplicate the sub and give it another name?

    Gary

  9. #9
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Surely, the problem is that the callback routine is passed a ribbon control. If you want to call that routine, you need to pass the control, which of course you don't have access too. You could fake it, if you don't use the control in your code, just pass any old dummy object, see what happens.
    ____________________________________________
    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

  10. #10
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    The other way is to have the main code in a procedure, and cal that from the callback procedure. You can call the main code from anywhere then.
    ____________________________________________
    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

  11. #11
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,724
    Location
    Quote Originally Posted by zoom38 View Post
    I marked it solved too soon. After using the editor and adding (control As IRibbonControl) to the appropriate sub header things work great on the ribbon. However, I found out that when other subs call one of the subs with the (control As IRibbonControl) it pops a compile error - "Argument not Optional". Adding (control As IRibbonControl) to the sub call that fails then gives a compile error - "Expected: list separator or )".
    Is there a way to call this sub from another routine?
    Or can it now only be used from the ribbon and I have to duplicate the sub and give it another name?

    Gary

    Might be quicker to post a small workbook with just enough code (callbacks, XML, etc.) to see the issue. Probably don't even need any data
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  12. #12
    VBAX Mentor
    Joined
    Jan 2006
    Posts
    323
    Location
    XLD I used a dummy object as you suggested and it worked. I was able to use the sub from the ribbon and from within another sub without error. I don't really understand why it would be necessary to add (control As IRibbonControl) to a sub for the ribbon to work in the first place. Seems to be unnecessary if adding (dummy) to the sub works.

    Paul I attached a small workbook to illustrate the issue I was experiencing.

    Thank you all for taking the time to work on my problem.
    "Solved"

    Gary
    Attached Files Attached Files

  13. #13
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Gary, it is needed because very often you want to access the control directly. For instance, I have a generic routine that I use for all of my callbacks that set the ribbon control's label. That same routine would be called for every control, so I take the control.Id and use it as my lookup value that determines the label caption to use.
    ____________________________________________
    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

  14. #14
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,724
    Location
    OK, but I'd keep the callback as a 'ribbon processor' and the calendar shower in another module (probably personal style) to avoid a dummy object

    Option Explicit
    
    'Callback for customButton2 onAction
    Sub Pop_Cal2(control As IRibbonControl)
        Show_Cal
    End Sub

    and


    Option Explicit
    
    Sub Show_Cal()
        Load C_Form
        C_Form.Caption = "Pop Calendar V6"
    '    C_Form.HelpLabel.Caption = "Insert Your Help Lable"
        C_Form.Show
        Unload C_Form
    
    End Sub
    Attached Files Attached Files
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  15. #15
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Quote Originally Posted by Paul_Hossler View Post
    OK, but I'd keep the callback as a 'ribbon processor' and the calendar shower in another module (probably personal style) to avoid a dummy object
    I gave the OP both options, but I think I would personally go the same way as you Paul.
    ____________________________________________
    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

  16. #16
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,724
    Location
    @XLD -- Yes (your #10), but since 1 JPG = 1K TXT, I thought some examples would be helpful (as well as FWIW a personal opinion)
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

Posting Permissions

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