Results 1 to 12 of 12
  1. #1
    2 Star Lounger
    Join Date
    Aug 2011
    Posts
    112
    Thanks
    35
    Thanked 3 Times in 3 Posts

    Using CommandBars versus the Ribbon

    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?

  2. #2
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,853
    Thanks
    4
    Thanked 259 Times in 239 Posts
    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.
    Andrew Lockton, Chrysalis Design, Melbourne Australia

  3. #3
    2 Star Lounger
    Join Date
    Aug 2011
    Posts
    112
    Thanks
    35
    Thanked 3 Times in 3 Posts
    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?

  4. #4
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,853
    Thanks
    4
    Thanked 259 Times in 239 Posts
    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.
    Andrew Lockton, Chrysalis Design, Melbourne Australia

  5. #5
    2 Star Lounger
    Join Date
    Aug 2011
    Posts
    112
    Thanks
    35
    Thanked 3 Times in 3 Posts
    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?
    Attached Files Attached Files

  6. #6
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,853
    Thanks
    4
    Thanked 259 Times in 239 Posts
    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
    Last edited by Andrew Lockton; 2016-04-23 at 02:11.
    Andrew Lockton, Chrysalis Design, Melbourne Australia

  7. The Following User Says Thank You to Andrew Lockton For This Useful Post:

    jrb (2016-04-23)

  8. #7
    2 Star Lounger
    Join Date
    Aug 2011
    Posts
    112
    Thanks
    35
    Thanked 3 Times in 3 Posts
    Hi Andrew,

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

  9. #8
    Silver Lounger Charles Kenyon's Avatar
    Join Date
    Jan 2001
    Location
    Sun Prairie, Wisconsin, Wisconsin, USA
    Posts
    2,049
    Thanks
    124
    Thanked 119 Times in 116 Posts
    You could also look at the Add-In on Greg Maxey's site which puts the Word 2003 Formatting and Standard Toolbars on the Ribbon.

    I think it is at the bottom of http://gregmaxey.mvps.org/word_tip_p...bbon_main.html

    Note, you still can't have floating toolbars. They have to be at the top unless you are modifying right-click menus.

    ----
    Edit,
    Nope it is on his Custom Menu Controls page. Search for "classic ui."
    Last edited by Charles Kenyon; 2016-04-25 at 20:01. Reason: add correct link
    Charles Kyle Kenyon
    Madison, Wisconsin

  10. #9
    2 Star Lounger
    Join Date
    Aug 2011
    Posts
    112
    Thanks
    35
    Thanked 3 Times in 3 Posts
    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?

  11. #10
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,853
    Thanks
    4
    Thanked 259 Times in 239 Posts
    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.
    Andrew Lockton, Chrysalis Design, Melbourne Australia

  12. #11
    2 Star Lounger
    Join Date
    Aug 2011
    Posts
    112
    Thanks
    35
    Thanked 3 Times in 3 Posts
    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
    Last edited by jrb; 2016-04-26 at 07:40.

  13. #12
    Silver Lounger Charles Kenyon's Avatar
    Join Date
    Jan 2001
    Location
    Sun Prairie, Wisconsin, Wisconsin, USA
    Posts
    2,049
    Thanks
    124
    Thanked 119 Times in 116 Posts
    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.
    Charles Kyle Kenyon
    Madison, Wisconsin

  14. The Following User Says Thank You to Charles Kenyon For This Useful Post:

    jrb (2016-04-26)

Posting Permissions

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