XL97: Errors If Module Contains Duplicate Subroutine Names

Last reviewed: January 9, 1998
Article ID: Q168605
The information in this article applies to:
  • Microsoft Excel 97 for Windows

SYMPTOMS

When you open a workbook in Microsoft Excel 97, you may receive the following error message:

   Compile error:
   Ambiguous name detected: <name of a macro>

If you delete the Visual Basic macro specified by the error message and then attempt to run a macro, compile your Visual Basic project, or save and close the workbook, you may receive the following error message:

   This program has performed an illegal operation and will be shut down.
   If the problem persists, contact the program vendor.

If you click Details, you receive an error message similar to either of the following:

   EXCEL caused an invalid page fault in module <unknown> at
   0000:00000009.

   EXCEL caused an invalid page fault in module VBA332.DLL at
   0137:651b397a.

CAUSE

The first problem occurs if a module in your workbook contains two or more subroutines with the same name. You receive the error message when you attempt to run a subroutine in the workbook, when you close the workbook, and when you open the workbook.

The second problem may occur if all of the following conditions are true:

  • A module in your workbook contains two or more subroutines with the same name. One of the subroutines is the last subroutine in the module. For example:

          Sub Alpha()
              '<code goes here>
          End Sub
    
          Sub Omega()
              '<code goes here>
          End Sub
    
          Sub Alpha()   'This is the duplicate subroutine.
              '<code goes here>
          End Sub
    
        -and-
    
    
  • You save and close the workbook. (NOTE: When you close the workbook, you receive the "Ambiguous name detected" error message.)

        -and-
    
  • When you reopen the workbook, you delete the duplicate subroutine.

        -and-
    
  • You then attempt to run a subroutine, compile the Visual Basic project by clicking Compile on the Debug menu, or save and close the workbook.

WORKAROUND

To prevent these problems from occurring, you must eliminate the duplicate subroutine names from the modules in the workbook. Because this process may cause invalid page faults to occur, it is strongly recommended that you close all open workbooks before performing these steps.

  1. Open the workbook. If you receive the "Ambiguous name detected" error message, proceed to step 2. If you do not receive the error message, the workbook does not contain duplicate subroutine names, and you can close the workbook.

  2. Click OK to dismiss the error message.

  3. In the Code window, either rename the subroutine with the duplicate name or delete it. Repeat until each subroutine in the module has a unique name.

  4. Repeat step 3 for each module in the workbook that contains duplicate subroutine names.

  5. When you are finished, click Close And Return To Microsoft Excel on the File menu. Or, press ALT+F11.

  6. On the File menu, click Save. Then, click Close on the File menu.

When you do this, you may receive the "Illegal Operation" error message described in the "Symptoms" section. If this occurs, you should restart your computer before attempting to use Microsoft Excel 97 again.

When you reopen the workbook, you should not receive the "Ambiguous name detected" error message. If you do, it may be necessary to rename all of the subroutines in the workbook.

STATUS

Microsoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.

MORE INFORMATION

In Microsoft Excel 97, a workbook can contain multiple subroutines with the same name. However, if a single Visual Basic module contains two or more subroutines with the same name, Microsoft Excel cannot distinguish between the two macros, and you will receive the "Ambiguous name detected" error message.

If the problems described in the "Symptoms" and "Cause" sections are already occurring, use the workaround described in the "Workaround" section to remove the duplicate subroutine names from the workbook. Note that in some cases, it may be necessary to rename ALL of the subroutines in your workbook in order to completely eliminate the problem.


Additional query words: 97 XL97
Keywords : xlgpf xlvbainfo kberrmsg kbprg
Version : WINDOWS:97
Platform : WINDOWS
Hardware : x86
Issue type : kbprb
Solution Type : kbworkaround


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: January 9, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.