Microsoft KB Archive/121268

{|
 * width="100%"|

XL5: GP Fault Setting PageSetup Object Property to Null

 * }

-

The information in this article applies to:


 * Microsoft Excel for Windows, version 5.0

-

SYMPTOMS
In Microsoft Excel, if you set the value of one of the PageSetup object header or footer properties, such as the RightFooter property, to Null in a Visual Basic procedure, you receive a general protection (GP) fault.

CAUSE
This problem occurs because the PageSetup object property is expected to be set to a string value, and cannot be set to the Null value. The Null value is a value indicating that a variable contains no valid data.

This problem occurs when you set any of the following properties of the PageSetup object to Null:

RightHeader

CenterHeader

LeftHeader

RightFooter

CenterFooter

LeftFooter

WORKAROUND
To avoid receiving a GP fault when you set the value of the PageSetup property, do not use the Null value. Instead, to clear the information in the header or footer on the worksheet, set the header or footer property of the PageSetup object to the value "". For example, to clear the information in the right footer on the current worksheet, use the following code:

  ActiveSheet.PageSetup.RightFooter = "" Microsoft provides examples of Visual Basic procedures 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 Visual Basic procedure is provided 'as is' and Microsoft does not guarantee that it can be used in all situations. Microsoft does not support modifications of this procedure to suit customer requirements for a particular purpose.

STATUS
Microsoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article. This problem was corrected in Microsoft Excel version 5.0c.