XL97: Problems with Arguments of PasteSpecial Method (255520)
The information in this article applies to:
- Microsoft Excel 97 for Windows
This article was previously published under Q255520 SYMPTOMS
If you write a Visual Basic for Applications macro
that uses the PasteSpecial method, the macro may not work correctly if it attempts to perform either of the following actions:
- Use the PasteSpecial method to paste validation.
- Use the PasteSpecial method to paste all information except borders.
For example, when the macro attempts to paste information except borders,
nothing is pasted.
Note that the same macro works as expected in versions of Microsoft
Excel prior to Excel 97.
CAUSE
This problem occurs because in Excel 97 the Paste argument used by the PasteSpecial method uses the wrong value; it uses the value 6 instead of the value 7.
Because the value 6 is used, the xlPasteAllExceptBorders constant
incorrectly causes validation formatting to be pasted.
To paste information other than borders, the xlPasteAllExceptBorders constant
should use a value of 7. When the value is 6, the xlPasteAllExceptBorders
constant causes the PasteSpecial method to paste validation formatting when
you run the macro.
There is no constant that causes all information except borders to be
pasted.
NOTE: There is no xlPasteValidation constant, either in Visual Basic or mentioned in the Help topic for the PasteSpecial method.
WORKAROUNDMicrosoft 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 the Microsoft fee-based
consulting line at (800) 936-5200. For more information about Microsoft Certified
Partners, please visit the following Microsoft Web site:
For more information about the support options that are available and about how to contact Microsoft, visit the following Microsoft Web site:
To work around this issue, use the Paste argument but set it to the
correct value. To do this, modify the macro so that it resembles one of the
following examples.
Paste Validation Only
To paste only validation formatting, change the value of the Paste argument
to 6, as in the following example:
Selection.PasteSpecial Paste:=6, Operation:=xlNone
NOTE: Microsoft recommends that you use this method instead
of using the xlPasteAllExceptBorders constant because the xlPasteAllExceptBorders constant does not perform
the correct operation.
To Paste All Information Except Borders
If you want to paste all copied information except borders, change the
value of the Paste argument to 7, as in the following example:
Selection.PasteSpecial Paste:=7, Operation:=xlNone
STATUSMicrosoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article. This problem was corrected in Microsoft Excel 2000.
Modification Type: | Major | Last Reviewed: | 5/13/2002 |
---|
Keywords: | kbbug kbdocerr kbdtacode kbProgramming KB255520 |
---|
|