G
Greg Maxey
I created a global Word Addin (template file "TestDoc.dotm" stored in the
Word startup directory) containing a standard project module "TestModule"
and the following code:
Option Explicit
Sub RunTest1()
MsgBox "Test 1 Sat"
End Sub
Function RunTestA(ByRef pStr As String) As String
RunTestA = "Test A Sat. Variable " & pStr & " passed sucessfully."
End Function
I then started Word and in a new document ran the following test of methods
for call a sub and function from a global template:
Sub Testing()
On Error GoTo Err_Handler
'These all work to call the routine.
Application.Run "RunTest1"
Application.Run "TestModule.RunTest1"
Application.Run "TestDoc.dotm!TestModule.RunTest1"
Application.Run MacroName:="RunTest1"
Application.Run MacroName:="TestModule.RunTest1"
Application.Run MacroName:="TestDoc.dotm!TestModule.RunTest1"
'These all work to call the function.
MsgBox Application.Run("RunTestA", "Test")
MsgBox Application.Run("TestModule.RunTestA", "Test")
MsgBox Application.Run(MacroName:="RunTestA", varg1:="Test")
MsgBox Application.Run(MacroName:="TestModule.RunTestA", varg1:="Test")
'While these don't. Why?
MsgBox Application.Run("TestDoc.dotm!TestModule.RunTestA", "Test")
MsgBox Application.Run(MacroName:="TestDoc.dotm!TestModule.RunTestA",
varg1:="Test")
Exit Sub
Err_Handler:
MsgBox Err.Description
Resume Next
End Sub
Can anyone explain why the last two calls to the function won't work?
Can anyone explain the use of the exclamation point "!" in the Macro name
string? What is this symbol, where is it defined or explained. What other
uses does it have?
Thanks.
--
Greg Maxey - Word MVP
My web site http://gregmaxey.mvps.org
McCain/Palin '08 !!!
Word startup directory) containing a standard project module "TestModule"
and the following code:
Option Explicit
Sub RunTest1()
MsgBox "Test 1 Sat"
End Sub
Function RunTestA(ByRef pStr As String) As String
RunTestA = "Test A Sat. Variable " & pStr & " passed sucessfully."
End Function
I then started Word and in a new document ran the following test of methods
for call a sub and function from a global template:
Sub Testing()
On Error GoTo Err_Handler
'These all work to call the routine.
Application.Run "RunTest1"
Application.Run "TestModule.RunTest1"
Application.Run "TestDoc.dotm!TestModule.RunTest1"
Application.Run MacroName:="RunTest1"
Application.Run MacroName:="TestModule.RunTest1"
Application.Run MacroName:="TestDoc.dotm!TestModule.RunTest1"
'These all work to call the function.
MsgBox Application.Run("RunTestA", "Test")
MsgBox Application.Run("TestModule.RunTestA", "Test")
MsgBox Application.Run(MacroName:="RunTestA", varg1:="Test")
MsgBox Application.Run(MacroName:="TestModule.RunTestA", varg1:="Test")
'While these don't. Why?
MsgBox Application.Run("TestDoc.dotm!TestModule.RunTestA", "Test")
MsgBox Application.Run(MacroName:="TestDoc.dotm!TestModule.RunTestA",
varg1:="Test")
Exit Sub
Err_Handler:
MsgBox Err.Description
Resume Next
End Sub
Can anyone explain why the last two calls to the function won't work?
Can anyone explain the use of the exclamation point "!" in the Macro name
string? What is this symbol, where is it defined or explained. What other
uses does it have?
Thanks.
--
Greg Maxey - Word MVP
My web site http://gregmaxey.mvps.org
McCain/Palin '08 !!!