C
Chad Knudson
I am having difficulty in trying to call a macro with parameters that
resides in another template file. While trying to track this down, I
simplified things to the code illustrated in the two subroutines I've
included in this message. If I include the project name in the MacroName
parameter to the Application.Run call, it fails with "Runtime Error 438:
Object doesn't support this property or method". If I remove the project
from the MacroName parameter to the Application.Run call, it successfully
runs.
In a module named modCustom in my Normal.dot template file I've added the
following two subs:
Public Sub TestCallParm(str As String)
MsgBox "This is a test. [" & str & "]"
End Sub
Public Sub TestSubWithParmCall()
Dim strTest As String
strTest = "Hello, World!"
Application.Run MacroName:="modCustom.TestCallParm", varg1:=strTest '
Succeeds
Application.Run MacroName:="Normal.modCustom.TestCallParm",
varg1:=strTest ' Fails
End Sub
Now, if I'm trying to call a sub without parameters it appears to work
properly as illustrated in the following two subs in the same module named
modCustom in Normal.dot:
Public Sub TestCall()
MsgBox "This is a test."
End Sub
Public Sub TestCallNoParm()
Application.Run MacroName:="Normal.modCustom.TestCall" ' Succeeds
End Sub
resides in another template file. While trying to track this down, I
simplified things to the code illustrated in the two subroutines I've
included in this message. If I include the project name in the MacroName
parameter to the Application.Run call, it fails with "Runtime Error 438:
Object doesn't support this property or method". If I remove the project
from the MacroName parameter to the Application.Run call, it successfully
runs.
In a module named modCustom in my Normal.dot template file I've added the
following two subs:
Public Sub TestCallParm(str As String)
MsgBox "This is a test. [" & str & "]"
End Sub
Public Sub TestSubWithParmCall()
Dim strTest As String
strTest = "Hello, World!"
Application.Run MacroName:="modCustom.TestCallParm", varg1:=strTest '
Succeeds
Application.Run MacroName:="Normal.modCustom.TestCallParm",
varg1:=strTest ' Fails
End Sub
Now, if I'm trying to call a sub without parameters it appears to work
properly as illustrated in the following two subs in the same module named
modCustom in Normal.dot:
Public Sub TestCall()
MsgBox "This is a test."
End Sub
Public Sub TestCallNoParm()
Application.Run MacroName:="Normal.modCustom.TestCall" ' Succeeds
End Sub