Results 1 to 11 of 11
  1. #1
    Star Lounger
    Join Date
    Mar 2006
    Posts
    63
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Macros and toolbars (Word 2007)

    I'm quite experienced at writing VBA-for-Word macros, and am now trying to understand what new tricks I need to learn to take advantage of Word 2007. I've looked at "what's new" in the Visual Basic Editor's help, and its "Overview of the Ribbon User Interface". Lots of stuff there I don't understand (COM Add-Ins, XML format files, etc).

    I guess I have a number of decisions to make, like:<UL><LI>Should I switch from VBA to XML (or even COM add-ins)?
    <LI>If so, where do I go to get started?
    <LI>Would someone like me (self-taught, but experienced) find the switch to XML easy enough (also self-taught with HTML)?
    <LI>Etc, etc, etc[/list]Any advice on which direction a lost soul should head to find light at the end of the tunnel, and on how they should get started?

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Macros and toolbars (Word 2007)

    You will still write your code in VBA -- or VB.Net if you prefer to create add-ins -- but you can no longer easily change the CommandBars. XML is used for structured data, and although there are a lot of complex and tedious reference materials on XML, I suspect that what you really need to know for Office Automation purposes probably is quite simple. Hopefully someone will issue some appropriately simple documentation. <img src=/S/smile.gif border=0 alt=smile width=15 height=15>

  3. #3
    Star Lounger
    Join Date
    Mar 2006
    Posts
    63
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Re: Macros and toolbars (Word 2007)

    Good!

  4. #4

  5. #5
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Christchurch, New Zealand
    Posts
    250
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Macros and toolbars (Word 2007)

    I started off really excited, I found a good book (RibbonX, customizing the Office 2007 Ribbon by Robert Martin, Ken Puls, and Teresa Hennig), through this found a little program called the Office 2007 Custom UI editor which saves trying to deal with xml in zip files (which I really couldn't get my head around - too many steps - and for some reason my laptop doesn't open zip files unless I use Winzip), and managed to create new tabs, and groups with simple buttons in the ribbon with call backs to VBA. However, now I'm trying to create a tab that contains a checkbox that should select which groups on this tab are displayed. The interface looks fine, but I can't get it to do anything! All of these articles on MSDN use examples of VB, Visual Studio or C# code, and I don't have the knowledge to rewrite that in VBA. Everything I have read so far leads me to believe that VBA should be able to handle this, but as I can't convert any of the examples to VBA I'm pretty stuck.

    Everything I've learnt about VBA has been self taught with help from forums such as this lounge and plenty of books, but the scarcity of information, even from Microsoft, is making me very frustrated. Perhaps I'm looking in the wrong place? Can anyone tell me where else to go to find help?

  6. #6
    Silver Lounger
    Join Date
    Jul 2001
    Location
    Ottawa, Ontario, Canada
    Posts
    1,609
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Macros and toolbars (Word 2007)

    Hi Karen
    <hr>these articles on MSDN use examples of VB, Visual Studio or C# code, and I don't have the knowledge to rewrite that in VBA.<hr>
    F.W.I.W. I don't recall an instance of attempting to do something in VBA where a VB example failed to work in the VBA environment.
    Regards
    Don

  7. #7
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,852
    Thanks
    4
    Thanked 259 Times in 239 Posts

    Re: Macros and toolbars (Word 2007)

    Why do you want to change the ribbon according to a checkbox? You haven't provided any of your current code or links to your sources so I can't determine where it isn't working for you.

    Rather than hide or show groups on a single tab an simpler method would be to build two tabs and show/hide or hide/show according to the checkbox setting. The coding for this should be shorter. The following link can be set to work in a couple of minutes. http://www.amazon.com/gp/blog/post/PLNK3ASJP94966O6L
    Andrew Lockton, Chrysalis Design, Melbourne Australia

  8. #8
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Christchurch, New Zealand
    Posts
    250
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Macros and toolbars (Word 2007)

    Hello Andrew,
    I have attached a zip file which contains the Word document that I am trying to work with. This will eventually be a template loaded into the Startup folder. It contains a description of what I am trying to achieve and why, along with pictures of the toolbars I am trying to replace with groups, and the XML code that makes up the customised tab, groups and buttons.

    Any help would be appreciated.

    Also, do you know with what program I can create my own images for buttons? Specifically png formats?

    Thanks.
    Attached Files Attached Files

  9. #9
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Christchurch, New Zealand
    Posts
    250
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Macros and toolbars (Word 2007)

    Hello Don,
    I have attached a zip file which contains two Excel files which each have code copied from the MSDN website, and which I can't work out how to get to work. The examples on MSDN say we can create these as customized documents, but then go on to talk about Visual Studio 2005 which is what I believe this code is aimed at. I haven't been able to find Visual Basic examples which actually work, which is why I thought that perhaps this code was not for VBA. I have no experience, nor do I own the product, of Visual Basic (.net or otherwise) or Visual Studio. I solely work in VBA.

    Any help would be appreciated, thanks.
    Attached Files Attached Files

  10. #10
    Silver Lounger
    Join Date
    Jul 2001
    Location
    Ottawa, Ontario, Canada
    Posts
    1,609
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Macros and toolbars (Word 2007)

    Hi Karen

    Regarding the first example (Demo - Customizing.xlsm). The MSDN website expected us to supply the details of the application object. So:
    applicationObject.Range("A1").Value = "You clicked the Insert Text button."
    Should change to something like:
    ThisWorkbook.Sheets(1).Range("A1").Value = "You clicked the Insert Text button."

    Regarding the second example (Demo-Groups.xlsm). I'm afraid that it is beyond me at the moment. Perhaps other loungers could pinpoint the problem. <img src=/S/sorry.gif border=0 alt=sorry width=15 height=15>
    Regards
    Don

  11. #11
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,852
    Thanks
    4
    Thanked 259 Times in 239 Posts

    Re: Macros and toolbars (Word 2007)

    This version has the toggles working and showing the groups but it doesn't remember the setting yet. You can see the Custom Document Property that I put in there to store this but I have run out of time to get that part working. Perhaps you can take it further to solve that bit.

    Try this link for help on that bit
    http://gregmaxey.mvps.org/MVP_Customize_Ribbon.htm

    On the PNG graphics front it depends on what software you already have. I would make the images with Corel PhotoPaint or Adobe Photoshop or Fireworks but I don't know what image software you have available. You could also try the opensource alternative of GIMP but all these are probably overkill for a simple icon image. Perhaps the suggestions here would be worth considering.
    Attached Files Attached Files
    Andrew Lockton, Chrysalis Design, Melbourne Australia

Posting Permissions

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