Some notes for this main forum Thread
https://eileenslounge.com/viewtopic.php?f=26&t=42984
https://web.archive.org/web/20071227....com/kb/190235 27 Dec 2007
WD97: Run Time Error 4366 Using Application.Run Command
Article ID : 190235
Last Review : January 23, 2007
Revision : 1.1
This article was previously published under Q190235
SYMPTOMS
When you run a Visual Basic For Applications macro containing the "Application.Run Macroname:=" command in Microsoft Word or in another Office program to automate Word, you may receive the following error message:
Run Time error '4366' : Unable to run the specified macro.
CAUSE
You have included a template name as part of the Macroname argument string.
RESOLUTION
Remove the template name from the Macroname argument.
WORKAROUND
To avoid naming conflicts among referenced projects, give your procedures unique names, so that you can call a procedure without specifying a project or module.
STATUS
Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article.
MORE INFORMATION
In the online Help, the Run method states that you can use the template name in the Macroname argument string, and then it shows the following examples as valid statements:
Visual Basic for Applications assigns names to macros in the following order:Code:Application.Run "Normal.Module1.MAIN" Application.Run "MyProject.MyModule.MyProcedure" Application.Run "'My Document.doc'!ThisModule.ThisProcedure"
When Visual Basic for Applications accesses the Microsoft Word Object model, a project can be either a template or document with stored procedures. In Visual Basic for Applications, the Word projects are named in the following manner:Code:project.module.procedure.
Normal - all modules stored in the Normal.dot
TemplateProject - all modules store in the first file in the Startup
folder (if more than one template is in the startup
folder, Word uses the one that was copied
to the folder first and not by the alphabetical
listing order).
Project - additional startup templates, the template the open
file is based on, or an open saved document with a
module.
The following illustration describes how Visual Basic for Applications handles Microsoft Word macros of the same name or macros and modules of the same name in different template and document projects that are active.
In Microsoft Word, if you open a document named MyDoc.doc that is based on the template MyTemp.dot, both documents have a module called "Newmacros" and a macro called "MyMacro." At Startup, a template called "MyStart.dot" loads with the "Normal.dot" global template. Both of these templates have a module called "Newmacros", and there is a macro called "MyMacro" in the module.
With the three templates and one document active in Microsoft Word, when the "Macro" dialog box appears, you see the following lines of code:
Open the Visual Basic Editor by pressing ALT+F11. Then press CTRL+R to view the following in Project Explorer:Code:Normal.NewMacros.Mymacro Project.NewMacros.Mymacro Project1.NewMacros.Mymacro TemplateProject.NewMacros.Mymacro
Normal(Normal)
Project(MyTemp)
Project(MyDoc)
TemplateProject(MyStart)
If you want to run the macro in MyStart.dot, write your code as follows:
- or -Code:Application.Run "TemplateProject.NewMacro.macro1"
________________________________________Code:Normal.NewMacros.Mymacro = Normal.dot Project.NewMacros.Mymacro = MyTemp.dot Project1.NewMacros.Mymacro = MyDoc.doc
APPLIES TO
• Microsoft Word 97 Standard Edition
Keywords: kbbug kbpending kbprb KB190235
https://web.archive.org/web/20090521....com/kb/190235 May 21 2009
Article ID: 190235 - Last Review: January 23, 2007 - Revision: 1.1
WD97: Run Time Error 4366 Using Application.Run Command
Retired KB Content Disclaimer
.
This article was previously published under Q190235
SYMPTOMS
When you run a Visual Basic For Applications macro containing the "Application.Run Macroname:=" command in Microsoft Word or in another Office program to automate Word, you may receive the following error message:
Run Time error '4366' : Unable to run the specified macro.
CAUSE
You have included a template name as part of the Macroname argument string.
RESOLUTION
Remove the template name from the Macroname argument.
WORKAROUND
To avoid naming conflicts among referenced projects, give your procedures unique names, so that you can call a procedure without specifying a project or module.
STATUS
Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article.
MORE INFORMATION
In the online Help, the Run method states that you can use the template name in the Macroname argument string, and then it shows the following examples as valid statements:
Visual Basic for Applications assigns names to macros in the following order:Code:Application.Run "Normal.Module1.MAIN" Application.Run "MyProject.MyModule.MyProcedure" Application.Run "'My Document.doc'!ThisModule.ThisProcedure"
project.module.procedure.
When Visual Basic for Applications accesses the Microsoft Word Object model, a project can be either a template or document with stored procedures. In Visual Basic for Applications, the Word projects are named in the following manner:
Normal - all modules stored in the Normal.dot
TemplateProject - all modules store in the first file in the Startup
folder (if more than one template is in the startup
folder, Word uses the one that was copied
to the folder first and not by the alphabetical
listing order).
Project - additional startup templates, the template the open
file is based on, or an open saved document with a
module.
The following illustration describes how Visual Basic for Applications handles Microsoft Word macros of the same name or macros and modules of the same name in different template and document projects that are active.
In Microsoft Word, if you open a document named MyDoc.doc that is based on the template MyTemp.dot, both documents have a module called "Newmacros" and a macro called "MyMacro." At Startup, a template called "MyStart.dot" loads with the "Normal.dot" global template. Both of these templates have a module called "Newmacros", and there is a macro called "MyMacro" in the module.
With the three templates and one document active in Microsoft Word, when the "Macro" dialog box appears, you see the following lines of code:
Open the Visual Basic Editor by pressing ALT+F11. Then press CTRL+R to view the following in Project Explorer:Code:Normal.NewMacros.Mymacro Project.NewMacros.Mymacro Project1.NewMacros.Mymacro TemplateProject.NewMacros.Mymacro
Normal(Normal)
Project(MyTemp)
Project(MyDoc)
TemplateProject(MyStart)
If you want to run the macro in MyStart.dot, write your code as follows:
- or -Code:Application.Run "TemplateProject.NewMacro.macro1"
Code:Normal.NewMacros.Mymacro = Normal.dot Project.NewMacros.Mymacro = MyTemp.dot Project1.NewMacros.Mymacro = MyDoc.doc
________________________________________
APPLIES TO
• Microsoft Word 97 Standard Edition
Keywords: kbbug kbpending kbprb KB190235
Retired KB Content Disclaimer
This article was written about products for which Microsoft no longer offers support. Therefore, this article is offered "as is" and will no longer be updated.




Reply With Quote
Bookmarks