Board index » delphi » Help! - Language independant Excel?

Help! - Language independant Excel?

I'm trying to export data to Excel using Automation.  I have an
OleVariant (XL : OleVariant), and I assign CreateOleObject
('Excel.Application'); to it.  Then I manipulate excel by calling
XL.Workbooks.count for example.

However on a client machine, the above call returns the error "Method
workbooks not supported by automation object"

This client is using Excel 7.0 - French version (I think it's French,
could be Dutch).

Is this error caused because they have a foreign language version of
Excel.  If so, how do I get around the multilingual issue?  I've read
on the Microsoft support site that all versions should support commands
written in English.

Has anyone experienced anything similar, and if so how did you solve
the problem?

Any help would really be appreciated!

Thanks,
Mark.

Sent via Deja.com http://www.deja.com/
Before you buy.

 

Re:Help! - Language independant Excel?


Hi Mark,

I've got the same problem and got a workaround.
BUT it depends on the target system.

If WinNT: simple!
  Just call SetThreadLocale(<english>) before any OleAutomation

If Win9x: much more difficult
  can't use SetThreadLocale because this does nothing (thanks MS)
  you have to patch the ComObj unit this way (and can't use packets):

unit ComObj;

...

procedure GetIDsOfNames(const Dispatch: IDispatch; Names: PChar;
  NameCount: Integer; DispIDs: PDispIDList);
...
  //Temp := Dispatch.GetIDsOfNames(GUID_NULL, NameRefs, NameCount,
  //  GetThreadLocale, DispIDs);
  Temp := Dispatch.GetIDsOfNames(GUID_NULL, NameRefs, NameCount,
    SysLocale.DefaultLCID, DispIDs);
...

So don't use SetThreadLocale(<english>) but assign
  SysLocale.DefaultLCID:=<english>;

Good luck.

Sent via Deja.com http://www.deja.com/
Before you buy.

Re:Help! - Language independant Excel?


Great,

Just sent a test program over to a client in Belgium who uses Dutch
Excel & he reports that everything worked fine.

I'd found the SetThreadLocale function, but damned Microsoft to
eternity when I saw the "Only supported on NT" clause.  Now with the
patched implementation of ComObj it works.

I'm extremely grateful for this - I was beginning to lose hope.  I was
suprised that this hasn't come up more often in the group.

Anyway, one further question - do you know how to create LCIDs?  The
Win 32 help states that there's a MakeLCID function, but Delphi doesn't
seem to know of it.  Instead I'm manually creating the LCID for English
using

(Sort_Default shl 16) or ((SubLang_English_Uk shl 10) or Lang_English)

but it's not particularly friendly looking in the code.

Thanks again,
Mark.

In article <7uk451$sv...@nnrp1.deja.com>,

Quote
  serge_v...@my-deja.com wrote:
> Hi Mark,

> I've got the same problem and got a workaround.
> BUT it depends on the target system.

> If WinNT: simple!
>   Just call SetThreadLocale(<english>) before any OleAutomation

> If Win9x: much more difficult
>   can't use SetThreadLocale because this does nothing (thanks MS)
>   you have to patch the ComObj unit this way (and can't use packets):

> unit ComObj;

> ...

> procedure GetIDsOfNames(const Dispatch: IDispatch; Names: PChar;
>   NameCount: Integer; DispIDs: PDispIDList);
> ...
>   //Temp := Dispatch.GetIDsOfNames(GUID_NULL, NameRefs, NameCount,
>   //  GetThreadLocale, DispIDs);
>   Temp := Dispatch.GetIDsOfNames(GUID_NULL, NameRefs, NameCount,
>     SysLocale.DefaultLCID, DispIDs);
> ...

> So don't use SetThreadLocale(<english>) but assign
>   SysLocale.DefaultLCID:=<english>;

> Good luck.

> Sent via Deja.com http://www.deja.com/
> Before you buy.

Sent via Deja.com http://www.deja.com/
Before you buy.

Re:Help! - Language independant Excel?


Hi Mark,

Quote
> Just sent a test program over to a client in Belgium who uses Dutch
> Excel & he reports that everything worked fine.

Pleased this has been helpful.

Quote
> Anyway, one further question - do you know how to create LCIDs?  The

Damned Microsoft ... again.
The MakeLCID "function" is not a function: it's a C macro

Salut.

Sent via Deja.com http://www.deja.com/
Before you buy.

Other Threads