The Run-time Error 438 in Outlook VBA typically occurs when you try to call a method or property that does not exist for the object you are working with. In your case, it seems that the issue arises when using Application.Run to call a subroutine dynamically from another module. Here are a few suggestions to troubleshoot and resolve this issue:
- Check the Subroutine Name: Ensure that the constructed name of the subroutine is correct. You can debug by printing the name to the Immediate Window before calling
Application.Runto verify it is what you expect. - Module Reference: Since you mentioned trying to prepend "ProcessingModule." to the subroutine name, ensure that the module name is correct and that the subroutine is declared as
Public. If the subroutine is private, it cannot be accessed from outside its module. - Use CallByName: While you mentioned that
CallByNamerequires an object, you can create a temporary object to hold your subroutine calls. For example, you can create a dummy object that contains your preprocessing methods as properties, which would allow you to useCallByNameeffectively. - Check for Typos: Double-check for any typos in the subroutine names or the way you are constructing the names dynamically. Even a small typo can lead to this error.
- Simplify the Call: If possible, simplify the call to just one or two subroutines to see if the error persists. This can help isolate whether the issue is with the dynamic construction of the name or with the subroutine itself.
- Debugging: Use breakpoints and step through your code to see exactly where it fails. This can provide insights into whether the problem is with the dynamic name resolution or something else.
If these steps do not resolve the issue, consider providing more specific details about the subroutine declarations and how they are structured within the ProcessingModule. This additional context could help further diagnose the problem.
References: