The information in this article applies to:
SYMPTOMSWhen you run a Visual Basic for Applications macro in Microsoft Excel 98 Macintosh Edition, you may receive the following error message:
CAUSE
This problem may occur if all of the following conditions are true:
-and- -and- WORKAROUND
Microsoft provides examples of Visual Basic for Applications 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. The Visual Basic procedures in this article are
provided 'as is' and Microsoft does not guarantee that they can be used in
all situations. While Microsoft support professionals can help explain the
functionality of a particular macro, they will not modify these examples to
provide added functionality, nor will they help you construct macros to
meet your specific needs. If you have limited programming experience, you
may want to consult one of the Microsoft Solution Providers. Solution
Providers offer a wide range of fee-based services, including creating
custom macros. For more information about Microsoft Solution Providers,
call Microsoft Customer Information Service at (800) 426-9400.
When run, the first macro (Macro1) initializes an array named X, populates
the array, and then sends a value from the array to the second macro
(Macro2). Macro2 then displays the value in a message box. If you run
Macro1 without applying any of the following workarounds, you will receive
the error message mentioned in the "Symptoms" section.
Method 1To prevent the problem from occurring, change how the second macro (Macro2) accepts values. In this case, change the second macro to
to eliminate the problem, because an element from an array of type Variant
is being sent to a variable of type Variant.
Method 2A second way to prevent the problem from occurring is to convert the value to an Integer as you pass it to the second macro using the CInt function.
Method 3Another way to prevent the problem from occurring is to dimension a second variable in the first macro. This second variable should be of the same type as the value accepted by the second macro. The value from the array is copied into the second variable, which is then sent to the second macro. For example:
Because Z is an Integer, the value of Z is received by Macro2 (which
expects an Integer) correctly.
STATUSThis behavior is by design of Microsoft Excel 98 Macintosh Edition. The behavior demonstrated by earlier versions of Microsoft Excel is actually incorrect. MORE INFORMATION
In earlier versions of Microsoft Excel, a value can be passed from an
element in an array of type Variant in one function to a variable of
another type in another function. This is called "automatic type coercion,"
because the value passed between functions is being forced (coerced) to
switch from one type (Variant) to another type (Integer, for example).
Additional query words: XL98
Keywords : kberrmsg kbprg kbdta kbdtacode xlvbahowto xlvbainfo xlvbmigrate |
Last Reviewed: November 4, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |