• Trying to run a macro from a different project (VBA 6 Word 2K)

    Home » Forums » AskWoody support » Productivity software by function » Visual Basic for Applications » Trying to run a macro from a different project (VBA 6 Word 2K)

    Author
    Topic
    #407705

    Hello out there

    In attempting to run a macro that is contained within another project I have tried the following code unsuccessfully. Can someone please tell me where I have erred?

    Word.Application.Run “D:MacrosMacroSource.About.About”

    Answers to questions you might ask:
    1. The called project is a template named “MacroSource.dot”
    2. Both the calling and called projects reside in the same directory
    3. Both projects are Word Templates

    Viewing 1 reply thread
    Author
    Replies
    • #854919

      Application.Run typically is used when the code container is “open” and “in scope” at the time you call the procedure. For example, MacroSource.dot could be open as a global template. You should be able to find the procedure in the macros dialog (unless it takes parameters, in which case Word does not display it there.)

      If the template is open, then the next issue is the syntax; a path to a file on disk shouldn’t be required, and actually you omitted the file name. For examples of syntax that should work, see post 335145 and post 234629. Someone may post and say that you can’t do it without setting a Reference to the other template under Tools>References. Just ignore him.

      If the template is not open or in scope, you either can open it yourself (perhaps by adding it as a global template) or perhaps someone has a solution that will dynamically open it.

    • #854920

      Application.Run typically is used when the code container is “open” and “in scope” at the time you call the procedure. For example, MacroSource.dot could be open as a global template. You should be able to find the procedure in the macros dialog (unless it takes parameters, in which case Word does not display it there.)

      If the template is open, then the next issue is the syntax; a path to a file on disk shouldn’t be required, and actually you omitted the file name. For examples of syntax that should work, see post 335145 and post 234629. Someone may post and say that you can’t do it without setting a Reference to the other template under Tools>References. Just ignore him.

      If the template is not open or in scope, you either can open it yourself (perhaps by adding it as a global template) or perhaps someone has a solution that will dynamically open it.

    Viewing 1 reply thread
    Reply To: Trying to run a macro from a different project (VBA 6 Word 2K)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: