• Using CommandBars versus the Ribbon

    • This topic has 11 replies, 3 voices, and was last updated 9 years ago.
    Author
    Topic
    #505376

    We just recently upgraded at work to office 2013. I used to use a customized ribbon when we had 2010, but for some reason it isn’t working anymore. Our comm has no idea, so I need another solution for at least the time being as it could be months and months before comm gets it figured out or authorized to use on our computers even though it worked before the upgrade.

    So, I know how to customize the ribbon and I’ve done so here at home. It works fine, but at work it’s even more troublesome as we can not have the Custom UI Editor on our computers.

    I’ve transferred the file to work via a CD (that’s the only way to get a .docm to the office — we are locked down pretty tight) and it does not work with the customized ribbon even though it works fine at home.

    I’ve check marked Word Options >> Advanced >> General >> Show ad-in user interface errors and get the message, “can’t use because of policy”.

    Anyway, I know commandbars has been an alternative in the past and the customized ribbon makes it almost obsolete, but in this case that’s what I need to use.

    Can somebody point me in the right direction for some code to do this in Word 2013?

    Viewing 8 reply threads
    Author
    Replies
    • #1561146

      Do you have Word 2013 at home where the ribbon works?

      I often move templates between versions so the ribbon can work in both versions but you need to be aware of what version of ribbon you have assigned. For instance, if your ribbon is using the Word 2010 settings it will work in Word 2010 and 2013 but not in older versions (2007).

      With your ribbon editor, you can add ribbon versions for each version of Word so it is possible you mistakenly added two ribbons, one for 2010 and one for 2013 but only populated the 2010 one so the empty 2013 ribbon is being asked to display in Word 2013. Check this is not the case in your template.

    • #1561151

      I have 2007 and 2016 at home, but on different computers.

      I first built the ribbon on the machine with 2007. It works fine at home. I took that file to work on the CD and it doesn’t work.

      On the 2007 machine, I used the Custom UI Editor and made two files, one with the Office 2010 Custom UI and one with the 2007.

      Again, neither one worked at the office.

      Am I right in thinking that is does no good to use the 2016 machine as it is not backwards compatible?

    • #1561165

      I haven’t found Office to have a problem with backwards compatibility but then again I haven’t moved to Word 2016 either. A Word 2007 ribbon works just fine on Word 2010 and Word 2013. If you are finding that to not be the case, perhaps your IT group have locked something they shouldn’t have.

      If you want to explore this further, perhaps you could post a copy of your template so we can verify the ribbon in Word 2013. If it works on other people’s machines then we can surmise the problem lies in the company-imposed restrictions rather than Word 2013 itself.

    • #1561168

      Hi Andrew,

      This is what I built in 2007 and is working fine. The customized tab is the last tab called Editing Help.

      If it works fine on another machine, do you know where to find some code for CommandBars in Word 2013?

    • #1561174

      Your ribbon works on my Word 2013 machine so the problem lies elsewhere.

      CommandBars is olde code relevant to pre-2007 versions so the buttons will appear in an Addins tab on your ribbon. Code to add a toolbar and a couple of buttons might work along these lines

      Code:
      Private Sub AddToolbar()
        Dim commandBar As Office.commandBar
        On Error Resume Next
          Set commandBar = ActiveDocument.AttachedTemplate.CommandBars("Test")
        On Error GoTo 0
        If commandBar Is Nothing Then ' Toolbar named Test does not exist so we should create it.
          Set commandBar = Application.CommandBars.Add("Test", 1, False, True)
        End If
       
        'Add a built-in button
        commandBar.Controls.Add Type:=msoControlButton, ID:=3, Before:=1
        'Add a custom button
        With commandBar.Controls.Add(Type:=msoControlButton, Before:=2)
          .OnAction = "'" & ActiveDocument.AttachedTemplate.Name & "'!" & "CntTables"
          .FaceId = 59
          .Caption = "Count the Tables"
          .Tag = "My_Tag"
        End With
        commandBar.Visible = True
      End Sub
    • #1561208

      Hi Andrew,

      This seems to do the trick. Now the big test, testing it at work on Monday. 🙂

    • #1561442

      Thanks Charles. From what I can tell, it looks like it still uses XML which our IT department has clamped down on.

      Once we upgraded to 2013, all the customized toolbars I use in my Excel workbooks are all now toast.

      Using Andrews code snippet above, I’ve been able to get the commandbar loaded and working.

      I have also considered just using a form to launch my code. Can I ask…is there a way to access my userform without using Alt+F8?

      I searched today for shortcut keys, but didn’t turn up anything promising.

      Also, is it possible to place some type of control on the word doc which allows you to fire up the userform, but would also not print?

      • #1561524

        Save your macro in your template or document. Attach a QAT icon to the macro, saving that also in the template or document. You can also, if you want, save a keyboard shortcut for your macro in the template or document.

    • #1561450

      VBA userforms are normally launched by a macro. For instance, if your userform was called ufCleanMe then a macro would say

      Code:
      Sub TextClean()
        ufCleanMe.Show
        ufCleanMe.Hide
        Unload ufCleanMe
      End Sub

      The .Show is the line that opens the userform. The other two won’t run until you close the displayed userform.

    • #1561457

      Hi Andrew,

      Yes, that part I am familiar with, although, I have never used the .hide before.

      My question, without using Alt+F8, what is the most efficient way for a user to interact with the form?

      Also, thank you for the code snippet for the CommandBar. It took awhile to search and find how to do a combination button with a facid and a caption, but finally got it. Thanks again

    Viewing 8 reply threads
    Reply To: Using CommandBars versus the Ribbon

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: