The xxxLocal Properties

Up until now, you have had to interact with Excel using English-language functions and the default U.S. formats. Presented now is an alternative situation, where your code interacts with the user in his or her own language using the appropriate regional settings. How, then, can your program take something typed in by the user (such as a number format or formula) and send it straight to Excel, or display an Excel formula in a message box in the user's own language?

Microsoft has anticipated this requirement and has provided us with local versions of most of the functions we need. They have the same names as their U.S. equivalents, with the word "Local" on the end (such as FormulaLocal, NumberFormatLocal, and so on). When you use these functions, Excel does not perform any language or format coercion for you. The text you read and write is exactly how it appears to the user. Nearly all of the older functions that return strings, or have string arguments, have local equivalents; newer objects do not. The following table lists all of the xxxLocal properties and the objects to which they apply.

Applies to

Return strings according to U.S. number and date formats and English text

Use and return locally formatted strings, and in the language used for the Office UI (or Windows version)

Number/string conversion

Str

Cstr

Number/string conversion

Val

CDbl, and so on

Name, Style, CommandBar

.Name

.NameLocal

Range, Chart Series

.Formula

.FormulaLocal

Range, Chart Series

.FormulaR1C1

.FormulaR1C1Local

Range, Style, Chart Data Label, Chart Axes Label

.NumberFormat

.NumberFormatLocal

Range

.Address

.AddressLocal

Range

.AddressR1C1

.AddressR1C1Local

Defined Name

.RefersTo

.RefersToLocal

Defined Name

.RefersToR1C1

.RefertToR1C1Local

Defined Name

.Category

.CategoryLocal

0 0

Post a comment