Page 1 of 2 12 LastLast
Results 1 to 15 of 17
  1. #1
    Star Lounger
    Join Date
    Feb 2001
    Location
    San Francisco, California, USA
    Posts
    67
    Thanks
    0
    Thanked 1 Time in 1 Post

    Copying menus between templates

    Hell, all,

    I'm trying to programmatically copy a custom menu (added to Word's native menu bar) from one template to another. I'm able to copy toolbars programmatically, but I've had no luck copying menus that way.

    Suggestions?

    Thanks.

    Bob

  2. #2
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Los Angeles Area, California, USA
    Posts
    7,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Copying menus between templates

    Hi Bob:
    I'll start by saying that I'm NOT a VBA expert. However, Chris Greaves, in another post on the Word forum, pointed out that you can't copy menus between templates in Word. His solution was to create what he called a shadow toolbar that contained all the entries that the menu had. You can place dropdown menus on toolbars & copy the toolbars. Then you can copy the buttons to a new menu in the target template. Hats off to Chris for this idea!!

    Hope this helps.

  3. #3
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Copying menus between templates

    > Hats off to Chris for this idea!!

    Kepp your hats on. It's -20c up here, and I'm follicly-challenged.

    Also I stole^H^H^H^H^H borrowed the idea from Woody's Lounge when it wasn't looking.

  4. #4
    Star Lounger
    Join Date
    Feb 2001
    Location
    San Francisco, California, USA
    Posts
    67
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Copying menus between templates

    Thanks, Phil. I've already tried it this way, without success. I'm going to ask Chris what I'm doing wrong.

    Bob

  5. #5
    Star Lounger
    Join Date
    Feb 2001
    Location
    San Francisco, California, USA
    Posts
    67
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Copying menus between templates

    Hi, Chris,

    Following Phil's advice, I checked your Word post re Making Custom Menus. I've tried something similar, but without success. Here's what I did:

    In the original template, I created a custom toolbar. On that toolbar, I created a drop-down menu. I then copied the module containing the macros from the original template to the target template. Then I copied the toolbar from the original template to the target template.

    The toolbar copied fine, but the menu on it was grayed out in the target template. Tried copying the toolbar a couple of times, both programatically and manually, with the same results.

    Am I missing something?

    By the way, here in San Francisco, we've all got our hats off today. Sunny and mid-60's...

  6. #6
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Copying menus between templates

    >, we've all got our hats off today. Sunny and mid-60's...

    >I'm going to ask Chris what I'm doing wrong.


    What's your first clue? That's right! YOU HAVEN'T INVITED ME DOWN THERE!!!


    >copied the toolbar from the original template to the target template.

    I suspect that this is the cause of your woes. My current understanding of how toolbars (don't) work is that when we drag a macro onto a toolbar, whether as a button or as a menu item or whatever, it's as if Word stores a full file path and name and module et al. with that, so that the link is very precious. You change the name of the directory, template name, module name, or almost anything and you're dead. The toolbar button/menuitem is now defunct.

    Trouble is, if it's a macro that works quickly with no visible effects, then you won't KNOW that it's not working!

    Try this.

    Create a template that is going to hold your toolbar and toolbar menu. Let's call this TOOLS.DOT.

    In Tools.dot create a toolbar. Let's call this Tools.

    In Tools.dot create a PUBLIC SUB for each individual macro you want to have on the toolbar. The SUB will do nothing for now, so if you wanted a handy GlueReturns macro, make yourself code like this in Tools.dot:

    <pre>Public Sub cmd_GlueReturns
    End Sub
    </pre>


    Test the macro by tapping the F5 function key while the text cursor is anywhere in the macro code. It does nothing, right? Because the macro body has no code.

    Use View, Toolbars, Customize to drag this do-nothing macro onto the toolbar or toolbar menu item. Customize the button as you will. Test it by clicking on the toolbar item. It still does nothing, right? Good! (A macro that does nothing is said to be bug-free, 100% guaranteed!!)

    Now you can drag the module that contains the real-working-version of the macro GlueReturns (different name than cmd_GlueReturns, right?) into your Tools.dot, and place a call to GlueReturns in your cmd-GlueReturns.


    <pre>Public Sub cmd_GlueReturns
    ' Cover procedure for Gluing returns
    Call GlueReturns
    End Sub
    </pre>



    Now click on your toolbar item again; this time Returns get Glued, right?


    Here's the benefit of this apparently convulted method: Suppose you inherit a module with a better chunk of code for glueing returns, and suppose GeoffW called his version GeoffGlueReturns. You can drag Geoff's module (GeoffGlue) into your Tools.dot where it should live quite happily with your original module which holds your GlueReturns. Just change the Call stamement so that your code looks like this:

    <pre>Public Sub cmd_GlueReturns
    ' Cover procedure for Gluing returns
    Call GeoffGlueReturns
    End Sub
    </pre>



    Your toolbar item still points to dear ole cmd_GlueReturns, so no naming links are broken. But you can change the body of cmd_GlueReturns with impunity.



    Now, there may well be a better way, because this is the FIRST way I found of doing this; it seems like a lot of work up front, but it pays me handsome dividends, especially when I need to make changes to my code. I can even have a SWITCHABLE toolbar item, because I could write my cmd_GlueReturns like this:

    <pre>Public Sub cmd_GlueReturns
    ' Cover procedure for Gluing returns
    If boolDebugging Then
    Call GeoffGlueReturns
    Else
    Call GlueReturns
    EndIf
    End Sub
    </pre>



    Where else but Woody's Lounge can you get run-time switchable toolbar customization. I actually use my strGP routines to get switches during the running of the application, from the INI file. It's something else again to see faces as everything switches to, say, French, without needing to exit the application!


    While we're at it, something to help you go to sleep tonight. That word "glueing" is rather weird with all those vowels run together, eh?

  7. #7
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Los Angeles Area, California, USA
    Posts
    7,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Copying menus between templates

    Hi Chris:

    I want to see if I have your method straight.

    1. First step, I invite you down to southern California. It's raining now, but should clear up & be warm soon!

    I have a menu called &Macros. Suppose it lists five macros we'll call M1 thru M5.

    2. I create a blank toolbar named Macros.

    3. Then, instead of adding my macros to it in a drop down menu, I create 5 new macros & call them:
    (Well, here's where I get confused, so that's my first question. I can't call them Public Sub cmd_M1,etc. I have to name them something that will have the first line come out like that. I'm not sure how to do that.)

    4. After I get 5 macros that say:

    Public Sub cmd_M1
    Public Sub cmd_M2
    ..........
    Public Sub cmd_M5

    I copy those macros to the dropdown menu on the Macros toolbar, right?

    5. Then I copy macros M1 through M5 to the same toolbar. I now have a toolbar with twice as many macros as I originally wanted, BUT this toolbar can be copied to another template & work?? Is that right?

    6. And if the macros toolbar works in the new template, I can then make a new macros menu by copying the
    Public Sub cmd_M1,etc.
    from the toolbar. Or did I screw up? I know I got the first step right![img]/w3timages/icons/grin.gif[/img]

  8. #8
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Copying menus between templates

    >BUT this toolbar can
    be copied to another template & work?? Is that right?

    No. This is not right and it will not work. Didn't you tell us you ran into problems tryuing to "copy toolbars".

    Try doing the steps I wrote in my previous post. If you have trouble understanding any one of them, just refer to it and we'll clear the matter up.

    So, Start by

    1. Create a template that is going to hold your toolbar and toolbar menu. Let's call this TOOLS.DOT.

  9. #9
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Los Angeles Area, California, USA
    Posts
    7,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Copying menus between templates

    Just as an addendum, I noticed that the term "shadow toolbar" came from a post by Charles Kenyon.

    See over here.

    But Chris has great ideas posted all over the forum, so it's "Hats off to both of them".

  10. #10
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Copying menus between templates

    >"Hats off to both of them".

    Thanks, but not me, not today. More snow, and, I'd guess, less hair than yesterday. It's a case of hair today, gone tomorrow.

  11. #11
    Platinum Lounger
    Join Date
    Dec 2000
    Location
    Queanbeyan, New South Wales, Australia
    Posts
    3,730
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Copying menus between templates

    That's not even worth a "keep away Charlotte" alert.
    Subway Belconnen- home of the Signboard to make you smile. Get (almost) daily updates- follow SubwayBelconnen on Twitter.

  12. #12
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Copying menus between templates

    At least you got my drift.

    Now to get back on topic. I've u/l UHood.zip to my web site. It attempts to show (as it grows) my idea of development of toolbar menus. The adventurous might like to try dragging (View, Toolbars, Customize) a macro button from a menu list onto the Toolbar proper.

    Then try dragging it back. I seem to recall having problems with this.

    Also if you are trying to do something with a menu on a toolbar and your fingers slip and you drag the menu right off the toolbar, you are DEAD. I don't recall ever being able to recover, aprt from Alt-F,C,N; Alt-F,1.

  13. #13
    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

    Re: Copying menus between templates

    I thought so, too. But I figured maybe Chris had said the same thing.

    For me there are a couple of key elements in successfully copying menus.

    1) The menu is created on a custom toolbar - even if you are planning on inserting it into the built-in menus.

    2) Macros first - then buttons/menus/toolbars.
    If you copy the toolbar before the macros or other features being accessed by the toolbar are in place, you'll end up with dead menus.

    3) The way I make toolbars (copying stuff back and forth between them), I have the best luck if I copy the toolbars three times. That is because a drop-down menu on one toolbar may actually have been created on another toolbar. If toolbar#1 has features that depend on toolbar#2 which depend on features on toolbar#1, Word gives up if the sought feature isn't right there at the moment of creation. Copying three times seems to be sufficient.

    What was said about macros also applies to AutoText entries. - AutoText first - then toolbars.

    Finally, when constructing or modifying a toolbar in a template have the template Open and Active. This seems to help solidify the Customization Context. [img]/S/yadda.gif[/img]
    Charles Kyle Kenyon
    Madison, Wisconsin

  14. #14
    Star Lounger
    Join Date
    Feb 2001
    Location
    San Francisco, California, USA
    Posts
    67
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Copying menus between templates

    Thanks to all for the great advice. Chris, I really like the idea of a menu wrapper for macros.

    But I still can't get things to work (maybe it's the sunny, 65 degree weather today - ah, spring fever!). When I copy my custom, menu-containing toolbar from one template to another, the menus are invariably dead in the target template.

    Doesn't matter whether I use wrappers or not, or whether I copy the macros first or not, or whether I copy them three times or more, or whether I do it manually or programatically.

    Could the problem be that I'm using Word 97 rather than Word 2000?

    Bob

  15. #15
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Copying menus between templates

    >I have the best luck if I copy the toolbars three times.

    How on EARTH did you stumble on THIS?!!!

Page 1 of 2 12 LastLast

Posting Permissions

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