Calling procedures with the same name
You can call a procedure located in any module in the same project as the active module just as you would call a procedure in the active module. However, if two or more modules contain a procedure with the same name, you must specify a module name in the calling statement, as shown in the following example:
Sub Main()
Module1.MyProcedure
End Sub
If you give the same name to two different procedures in two different projects, you must specify a project name when you call that procedure. For example, the following procedure calls the Main
procedure in the MyModule
module in the MyProject.vbp
project.
Sub Main()
[MyProject.vbp].[MyModule].Main
End Sub
Note
Different applications have different names for a project. For example, in Microsoft Access, a project is called a database (.mdb); in Microsoft Excel, it's a workbook (.xls).
Tip
- If you rename a module or project, be sure to change the module or project name wherever it appears in calling statements; otherwise, Visual Basic will not be able to find the called procedure. Use the Replace command on the Edit menu to find and replace text in a module.
- To avoid naming conflicts among referenced projects, give your procedures unique names so you can call a procedure without specifying a project or module.
See also
Support and feedback
Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기