Microsoft Knowledge Base |
|
XL5: Problems When Procedure Has Same Name as Module Sheet |
|
|
Last reviewed: March 27, 1997
Article ID: Q120794 |
|
5.00 5.00c 7.00 | 5.00
WINDOWS | MACINTOSHkbother kbcode The information in this article applies to:
SYMPTOMSIn Microsoft Excel, you may encounter problems using Visual Basic, Application Edition, procedures and functions that have the same names as module sheets in the same workbook.
ProcedureWhen you call a procedure that has the same name as a module sheet in the workbook, you may receive the following error message:
Expected variable or procedure, not module Auto_Open or Auto_Close ProcedureIf you have an Auto_Open procedure and a module sheet is named Auto_Open in the same workbook, the Auto_Open procedure will not run when the workbook is opened. However, you will not receive an error message. The same behavior occurs when you are using a workbook that contains both an Auto_Close procedure and a Module sheet named Auto_Close; the Auto_Close macro will not run when the workbook is closed, and you will not receive an error message.
FunctionWhen you call a function with the same name as a module sheet in the workbook, you may receive the following error message:
Type mismatchWhen you reference a function from a worksheet, and the function has the same name as a module sheet in the workbook, you may receive the following error message:
Expected Procedure, not Module WORKAROUNDS
To call a procedureTo work around this problem when you call a procedure that has the same name as a module sheet in the workbook, do either of the following:
To use an Auto_Open or Auto_Close procedureWhen an Auto_Open (or Auto_Close) procedure and a module sheet named Auto_Open (or Auto_Close) are in the same workbook, you must rename the module sheet.
To call a functionTo work around this problem when you call a function that has the same name as a module sheet in the workbook, change the code for the procedure to:
Sub Example2()
Dim x as integer
x=Module1.Module1
Msgbox x
End Sub
-or-
To work around the problem when referencing a function from a worksheet if the function has the same name as a Module sheet in the workbook, do either of the following:
STATUSMicrosoft has confirmed this to be a problem in Microsoft Excel versions 5.x and 7.0. We are researching this problem and will post new information here in the Microsoft Knowledge Base when it becomes available.
|
|
KBCategory: kbother kbcode
©1997 Microsoft Corporation. All rights reserved. Legal Notices. |