Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

OFF97: Invalid Page Fault with More Than 411 Controls in UserForm


View products that this article applies to.

This article was previously published under Q177842

↑ Back to the top


Symptoms

When a UserForm has more than 411 controls and any controls added after the 411th are addressed directly by name in a Microsoft Visual Basic for Applications macro or procedure (for example, UserForm1.Label412), you receive one of the following error messages.

In Microsoft Windows 95

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 the following:
EXCEL caused an invalid page fault in module <unknown> at 0000:00000000.
-or-
WINWORD caused an invalid page fault in module <unknown> at 0000:00000000.
In Microsoft PowerPoint, you receive the following error message:
PowerPoint found an error that it can't correct. You should save presentations, exit, and then restart PowerPoint.

In Microsoft Windows NT

Dr. Watson for Windows NT
An Application error has occurred and an application log is being generated.
EXCEL.exe
Exception: Access violation (0xc0000005), Address: 0x00000000
-or-
WINWORD.exe
Exception: Access violation (0xc0000005), Address: 0x00000000

↑ Back to the top


Cause

This behavior occurs when the following conditions are true:
  • More than 411 controls of any type are created on a UserForm. -and-

  • Controls created after the 411th are addressed directly by name (such as UserForm1.Label412) in a Visual Basic macro or procedure.

↑ Back to the top


Workaround

Microsoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft support professionals can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific needs.
If you have limited programming experience, you may want to contact a Microsoft Certified Partner or Microsoft Advisory Services. For more information, visit these Microsoft Web sites:

Microsoft Certified Partners - https://partner.microsoft.com/global/30000104

Microsoft Advisory Services - http://support.microsoft.com/gp/advisoryservice

For more information about the support options that are available and about how to contact Microsoft, visit the following Microsoft Web site:http://support.microsoft.com/default.aspx?scid=fh;EN-US;CNTACTMS Controls beyond the 411th control must be addressed as a member of the Controls collection instead of addressed by name directly. You can use one of the following methods to work around the problem.

Method 1: Using a For Each...Next Statement

Refer to the desired control using the Controls collection and a For Each...Next statement. The following sample Sub procedure demonstrates this method:
   Sub Change_Caption()
      For each myControl in UserForm1.Controls
         x = x + 1
         myControl.Caption = x
      Next
   End Sub
				

Method 2: Using the Item Method

Use the Item method with the index number as the following sample Visual Basic statements demonstrate:
   UserForm1.Controls.Item(411).Caption = "joe"
				
-or-
   UserForm1.Controls(411).Caption = "joe"
				
-or-
   UserForm1.Controls("Label411").Caption = "joe"
				
NOTE: The index starts at 0.

↑ Back to the top


Status

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

↑ Back to the top


More information

Deleting a control with a TabIndex property number less than 411 allows the next named control above the previous 410 to be addressed without error, but the error then occurs on the control that becomes the 411th after the deletion. Changing the TabOrder property or TabIndex property number of a control does not change the behavior; the behavior seems to be entirely determined by the order in which the controls were created.

↑ Back to the top


References

For additional information about getting help with Visual Basic forApplications, click the article number below to view the article in the Microsoft Knowledge Base:
163435� VBA: Programming Resources for Visual Basic for Applications

↑ Back to the top


Keywords: kbbug, kbcode, kberrmsg, kbprogramming, KB177842

↑ Back to the top

Article Info
Article ID : 177842
Revision : 8
Created on : 1/22/2007
Published on : 1/22/2007
Exists online : False
Views : 444