Results 1 to 5 of 5
  1. #1
    3 Star Lounger
    Join Date
    Mar 2003
    Location
    Elkins Park, Pennsylvania, USA
    Posts
    325
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Custom Menus Redux: Dirty Normal? (Word XP)

    Good morning!
    I have created a document template called Protocol.dot that has a DocumentOpen procedure that I have programmed to create a custom menu. Specifically, if an add-in named WPC.dot is loaded, the Protocol template adds a menu (in the form of a popup control) to the end of the WPC.dot's toolbars. The reason for this selective behavior is that I only want certain people (those using WPC.dot) to use certain commands. (I know it's not bulletproof, but that's not the point.) The menu is similarly removed from the WPC add-in when the Protocol template (or the document based on it) is closed.

    To add the popup control, I determine if the add-in is loaded. If it is, I open the template as a document (Visible:=False), identify the desired toolbar, and work with it. (See the first three "Set" commands in the code.)

    What I'm finding is that, after the DocumentOpen procedure creates the menu, the Normal template's Saved property is False. I've debugged all afternoon and I know it's OK (i.e it's saved) before I add the menu, but it's dirty after the menu has been added.

    My question is: why?? All of my references are to the add-in template, as far as I can tell. I'm posting the code here in hopes that someone might enlighten me.
    Attached Files Attached Files
    <font face="Comic Sans MS">That's what you do in a herd; you look out for each other!</font face=comic> - Mike

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 28 Times in 28 Posts

    Re: Custom Menus Redux: Dirty Normal? (Word XP)

    Contrary to what you might expect, using WPCAddIn.CommandBars does not imply that modifications to commandbars will be stored in WPCAddIn, so modifications to commandbars will "dirty" Normal.dot, unless you explicitly set the CustomizationContext to another document or template. You could use CustomizationContext = WPCAddIn.

  3. #3
    3 Star Lounger
    Join Date
    Mar 2003
    Location
    Elkins Park, Pennsylvania, USA
    Posts
    325
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Custom Menus Redux: Dirty Normal? (Word XP)

    Very cool. Thank you!
    Another question: In order to refer to the CommandBarControl in the Addin, I've been opening the template to get a reference to it as a document. Is that the normal way of getting a reference to that Addin's CommandBar? I thought I could refer to it via the Templates collection, but it seems that a Template object doesn't even have a CommandBars collection associated with it.
    <font face="Comic Sans MS">That's what you do in a herd; you look out for each other!</font face=comic> - Mike

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 28 Times in 28 Posts

    Re: Custom Menus Redux: Dirty Normal? (Word XP)

    No, you don't need to open the add-in (template) as a document to get at the command bar. You can just refer to it by its name.

    I have to say this is very confusing. It doesn't matter whether you use CommandBars or Application.CommandBars or ActiveDocument.CommandBars, you get the same collection: all currently available command bars, i.e. those in the active document, those in the template attached to the document, those in Normal.dot and those in all global templates=add-ins.

  5. #5
    3 Star Lounger
    Join Date
    Mar 2003
    Location
    Elkins Park, Pennsylvania, USA
    Posts
    325
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Custom Menus Redux: Dirty Normal? (Word XP)

    Most excellent!
    Hans, I always learn much from your replies and posts.
    <font face="Comic Sans MS">That's what you do in a herd; you look out for each other!</font face=comic> - Mike

Posting Permissions

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