Excel language

  • Thread starter Thread starter Marco
  • Start date Start date
M

Marco

I am opening an Excel workbook with the code:
If ExcelRuns() Then
Set oapp = GetObject(, "Excel.Application")
Else
Set oapp = CreateObject("Excel.Application")
End If
This all works fine. I can open an Excel file and change
stuff in it.
However somewhere in the code I want to select a sheet:

oapp.sheets("sheet" & i).SELECT

Unfortunately in Dutch a "sheet" is called a "blad" so
when a Dutch version of Excel runs this code generates an
error.
Is there a way to find out which version of Excel is
running so I can use code like:

If oapp.???.language = "US" Then
oapp.sheets("sheet" & i).SELECT
Else 'Dutch in this case
oapp.sheets("blad" & i).SELECT
End If
I could not find a property of the object which shows the
language of the Excel running but perhaps there is a way
to obtain this information.

Many thanks
Marco
 
Marco,

You could use something like:

On Error GoTo DutchSS
oapp.sheets("sheet" & i).SELECT
GoTo Continue
DutchSS:
oapp.sheets("blad" & i).SELECT
Continue:
On Error GoTo 0 '(or your error handler)
.....
The rest of your code

HTH,
Nikos
 
Hi Marco,

One simple approach would be to just use the numeric index of the
collection

oApp.Worksheets(i).Select

or else you could try something like this:

Dim strPrefix As String

strPrefix = oApp.Worksheets(1).Name
strPrefix = Left(strPrefix, Len(strPrefix) - 1)
oApp.Worksheets(strPrefix & i).Select

But you may get a better answer if you post in an Excel forum.
 
Back
Top