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

    Module/Procedure Ambiguity (VBA/Word/2003-2007)

    I have a project which is distributed to a number of users as an add-in. On Launching Word the add-in rebuilds the command bar which is specific to its procedures. Some of my users have outdated versions of the add-in's modules stored in their Normal.dot templates. I find that the outdated macros are being fired in these cases.

    The OnAction command is:
    cbb.OnAction = "module.procedure"

    The add-in project appears in the Project Explorer as "Macros (_1_Macros)"

    How can I revise the code to force use of the add-in procedure? Surely it's possible.
    Regards
    Don

  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: Module/Procedure Ambiguity (VBA/Word/2003-2007)

    It should be automatic that add-ins take precedence over Normal.dot:
    <hr>Conflicting Customizations

    Because you can store customizations in multiple locations and the scope of customizations in one location can overlap the scope of those in another location, conflicts can arise. To resolve such conflicts, Word assigns precedence to customizations according to the following locations:
    1. <LI>The active document. Customizations stored in the active document take precedence over any other customizations that are present.

      <LI>The template attached to the active document. Customizations stored in the template attached to the active document take precedence over customizations stored in add-in files or in the default global template (Normal.dot).

      <LI>Add-in files, in order of loading. The most recently loaded add-in file takes precedence over add-in files loaded earlier.

      Note: Because you can load add-in files automatically from the Word Startup folder, or from the Microsoft Office Startup folder, and manually from any location at any time, there is no way to determine that your file will load before or after any other particular add-in file.

      <LI>The default global template (Normal.dot). Customizations stored in the default global template are loaded first, which means that customizations stored in all other locations can overwrite them.
    <hr>
    See: Customizing Word 2003 -- Conflicting Customizations

  3. #3
    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: Module/Procedure Ambiguity (VBA/Word/2003-2007)

    You could try the different syntax options documented for Application.Run and see whether those help in calling the correct procedure. See Run Method [Word 2007 Developer Reference] @ MSDN and your thread Application.Run (VBA/Excel/2003).

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

    Re: Module/Procedure Ambiguity (VBA/Word/2003-2007)

    Thanks for the response Jefferson.
    I think that we have a small disconnect.
    My customization consists of deleting a specific command bar and rebuilding it. As I understand the situation, this customization is vulnerable to modification by other add-ins which might be loaded subsequent to mine. I do not believe that this is my problem.
    The command button apparently will only accept the OnAction data in the form of "Procedure", or "Module.Procedure". There does not appear to be any way to define the file containing the module,
    Please correct me if I am wrong; as it will make the following workaround unnecessary,


    Workaround

    <UL><LI>Create a new module named MacroRedirect
    <LI>Within MacroRedirect create a procedure for each of the macros which is to be fired by the Command bar.
    <LI>Each of these procedures will consist of only one command Call Module.Procedure
    <LI>Revise the OnAction commands in the customization module to OnAction = "MacroRedirect.MyProcedure" [/list] This should always call the correct macro as VBA will start looking for the called procedure in the object closest to the calling procedure.
    Regards
    Don

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

    Re: Module/Procedure Ambiguity (VBA/Word/2003-2007)

    Can you not add into the OnAction data a third form of "Project.Module.Procedure" where Project is the name defined in the Properties section of the Template itself?

    I would be interested to see how your code produces the command bars in Word 2007. I have been doing these as an XML file rather than the same method as earlier versions of Word.
    Andrew Lockton, Chrysalis Design, Melbourne Australia

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

    Re: Module/Procedure Ambiguity (VBA/Word/2003-2007)

    Thanks for the thought Andrew.

    >> Can you not add into the OnAction data a third form of "Project.Module.Procedure" where Project is the name...

    I have tried all three names --see graphic -- in the manner you suggested; each produced the same results "cannot find the macro".

    Building the command bar in 2007 uses the same code as 2003, There are two anomalies though; a discussion on these and a copy of the command bar build code can be found in the thread which starts <!post=here,735800>here<!/post>.
    Attached Images Attached Images
    Regards
    Don

Posting Permissions

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