Professional Documents
Culture Documents
To determine if it is Excel 97 or
Excel 2000, use the following function. It returns an 8 if Excel 97, a 9 if Excel 2000, and most
likely a 10 for the next release of Excel.
This applies to XLA projects as much as it applies to XLS projects. Unfortunately, a utility is
available that will crack VBA project passwords across Office 97, so, again, this protection only
works against casual users.
If you are concerned that you need more heavyweight protection then you should consider
wrapping your most important code in an ActiveX DLL (most Excel code can be ported pretty
much straight into VB5 or VB6 with a few tweaks to object references) and calling that from a
protected XLA.
Excel 2000 has a reverse InStr, a routine to split the elements of a delimited string into elements
of an array,. It also has a routine like the worksheet function SUBSTITUTE. There are also
some new features relating to macro security. You have the ability to "sign" your VBA code in
Excel 2000. This allows users with Excel 2000 to automatically accept your code as safe when
they set macro security to High.
There are many cosmetic changes. You can get a complete list of new additions through the help
topic: What's New for Microsoft Excel 2000 Developers In 2000 VBA help
If you don't use any of the new things, your code should run in Excel 97. If you are developing
applications for Excel 97 users, you should do the development in Excel 97 to insure
compatibility.
23
A frequently asked question regarding Excel is about the existence of a run-time version of Excel
for users who do not have Excel installed on their machines, but need to run macros or access
data in Excel workbooks. The answer is straight forward: There is not a run-time version of
Excel. Each user must purchase a copy of Excel.
However, you can put your data in Excel workbooks and distribute those files to your audience
even if they don't have Excel. They would have to have the Excel viewer available free from the
Microsoft Web site. They would be able to look at your files, as if they were pictures - they
would not be able to change the values or enter data and run macros.
Microsoft Excel is published in over 30 languages. You can determine the language version by
using Application.International(xlCountryCode). It returns a number that indicates which
language is in use:
24
For example
Sub LanguageUsed()
The following illustrates how to determine if the user is using a US version of Excel.
If Application.International(xlCountryCode)=1 Then
MsgBox "US"
Else
MsgBox "Not US"
End If
The main problem with writing code for other languages typically has been currency. Microsoft
Excel will sometimes default to the U.S. conventions of currency separators with obviously
unsatisfactory results.
If you want users to enable macros when they open a file, you should have the file open onto a
worksheet with a message saying "If you see this message then you did not enable macros and
they macro features of this workbook are disabled." If the user enables macros, then simply hide
this worksheet as the first command in a subroutine named "Auto_Open".
'decimal separator:
'Day symbol and a statement that displays the day in a message box
25
Dim sDay As String
sDay = Application.International(xlDayCode)
MsgBox Format(Now(), sDay & sDay & sDay & sDay)
'currency code:
The following are just a few of the index values for International() queries
xlCountrySetting Long Current country setting in the Windows Control Panel, or the country
number as determined by your Macintosh system
software.
xlLeftBracket String Character used instead of the left bracket ([) in R1C1-style relative
references.
xlRightBracket String Character used instead of the right bracket (]) in R1C1-style references.
xlLeftBrace String Character used instead of the left brace ({) in array literals.
xlRightBrace String Character used instead of the right brace (}) in array literals.
26
xlColumnSeparator String Character used to separate columns in array literals.
xlAlternateArraySeparator String Alternate array item separator to use if the current array
separator is the same as the decimal separator.
0 = ($x) or (x$)
1 = -$x or -x$
2 = $-x or x-$
3 = $x- or x$-
27
Note that the position of the currency symbol is determined by xlCurrencyBefore.
0 = month-day-year
1 = day-month-year
2 = year-month-day
xl24HourClock Boolean True if using 24-hour time, False if using 12-hour time.
xlMetric Boolean True if using the metric system, False if using the English measurement
system.
xlCurrencyBefore Boolean True if the currency symbol precedes the currency values, False if it
follows them.
xlCurrencyMinusSign Boolean True if using a minus sign for negative numbers, False if using
parentheses.
xlCurrencyTrailingZeros Boolean True if trailing zeros are displayed for zero currency values.
xlCurrencyLeadingZeros Boolean True if leading zeros are displayed for zero currency values.
xlMonthLeadingZero Boolean True if a leading zero is displayed in months (when months are
displayed as numbers).
28
xl4DigitYears Boolean True if using four-digit years, False if using two-digit years.
xlMDY Boolean True if the date order is month-day-year for dates displayed in the long form,
False if the date order is day-month-year.
Application.Cursor = xlWait
To set it back, which you must do before your code completes, use the following statement:
Application.Cursor = xlDefault
If you do not set it back (for example an error occurs that crashes your code), then the cursor will
stay an hourglass.
or
In the immediate window, you can get the a value by typing a question mark and a valid
statement:
?ActiveCell.Value
29