[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.excel.programming

RE: Two excel version conflict?

Feather

12/20/2006 2:20:00 AM

it's C# code, I am not sure if this is the right place...
please let me know if there're somewhere else I can put this question to...

"feather" wrote:

> my program worked fine with excel 2002, but when my user installed an old
> excel version 2000 (i.e. the user has 2002 and 2000 on his pc now), my
> program throw exception when calling the open function...please help...
>
> my code:
>
> oExlApp = new Excel.Application();
> oExlApp.Visible = false;
> oExlWB = (Excel._Workbook) oExlApp.Workbooks.Open(strSrcFileName,
> Missing.Value, true, Missing.Value, Missing.Value, Missing.Value,
> Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value,
> Missing.Value, Missing.Value, Missing.Value , Missing.Value);
>
4 Answers

NickHK

12/20/2006 2:42:00 AM

0

From what I understand about C# (not much), all arguments must be included,
unlike VB/VBA where optional arguments can be omitted.
As the newer version has extra (optional) arguments compared to the older
version, these call will fail.
Maybe you need late binding and test the version of Excel to decide which
calls to make.

But it is generally advised to develop on the oldest system you intend
support.

NickHK

"feather" <feather@discussions.microsoft.com> wrote in message
news:8AF4D029-B090-4B88-90BF-631C69E5CC59@microsoft.com...
> it's C# code, I am not sure if this is the right place...
> please let me know if there're somewhere else I can put this question
to...
>
> "feather" wrote:
>
> > my program worked fine with excel 2002, but when my user installed an
old
> > excel version 2000 (i.e. the user has 2002 and 2000 on his pc now), my
> > program throw exception when calling the open function...please help...
> >
> > my code:
> >
> > oExlApp = new Excel.Application();
> > oExlApp.Visible = false;
> > oExlWB = (Excel._Workbook) oExlApp.Workbooks.Open(strSrcFileName,
> > Missing.Value, true, Missing.Value, Missing.Value, Missing.Value,
> > Missing.Value, Missing.Value, Missing.Value, Missing.Value,
Missing.Value,
> > Missing.Value, Missing.Value, Missing.Value , Missing.Value);
> >


Feather

12/20/2006 3:14:00 AM

0

when I develop & deploy my program, the user have the same enviroment as me,
only excel 2002. After a while, he installed 2000 to open some perticular xls
file which have some function only available under 2000 (no idea what it
is...). Anyway, that's why I got this issue.

Yes I think late binding is a good idea, could you tell me how to do this in
C#?

Thanks a lot!

"NickHK" wrote:

> From what I understand about C# (not much), all arguments must be included,
> unlike VB/VBA where optional arguments can be omitted.
> As the newer version has extra (optional) arguments compared to the older
> version, these call will fail.
> Maybe you need late binding and test the version of Excel to decide which
> calls to make.
>
> But it is generally advised to develop on the oldest system you intend
> support.
>
> NickHK
>
> "feather" <feather@discussions.microsoft.com> wrote in message
> news:8AF4D029-B090-4B88-90BF-631C69E5CC59@microsoft.com...
> > it's C# code, I am not sure if this is the right place...
> > please let me know if there're somewhere else I can put this question
> to...
> >
> > "feather" wrote:
> >
> > > my program worked fine with excel 2002, but when my user installed an
> old
> > > excel version 2000 (i.e. the user has 2002 and 2000 on his pc now), my
> > > program throw exception when calling the open function...please help...
> > >
> > > my code:
> > >
> > > oExlApp = new Excel.Application();
> > > oExlApp.Visible = false;
> > > oExlWB = (Excel._Workbook) oExlApp.Workbooks.Open(strSrcFileName,
> > > Missing.Value, true, Missing.Value, Missing.Value, Missing.Value,
> > > Missing.Value, Missing.Value, Missing.Value, Missing.Value,
> Missing.Value,
> > > Missing.Value, Missing.Value, Missing.Value , Missing.Value);
> > >
>
>
>

NickHK

12/20/2006 6:45:00 AM

0

That's a question for a C# NG.
In VB/VBA, you do not set a reference and only use the generic Object
variable with CreateObject:

Dim XLApp as object
set xlapp=createobject("Excel.Application")
'etc

NickHK

"feather" <feather@discussions.microsoft.com> wrote in message
news:0482DF47-B354-4078-803B-2367F3AEC99B@microsoft.com...
> when I develop & deploy my program, the user have the same enviroment as
me,
> only excel 2002. After a while, he installed 2000 to open some perticular
xls
> file which have some function only available under 2000 (no idea what it
> is...). Anyway, that's why I got this issue.
>
> Yes I think late binding is a good idea, could you tell me how to do this
in
> C#?
>
> Thanks a lot!
>
> "NickHK" wrote:
>
> > From what I understand about C# (not much), all arguments must be
included,
> > unlike VB/VBA where optional arguments can be omitted.
> > As the newer version has extra (optional) arguments compared to the
older
> > version, these call will fail.
> > Maybe you need late binding and test the version of Excel to decide
which
> > calls to make.
> >
> > But it is generally advised to develop on the oldest system you intend
> > support.
> >
> > NickHK
> >
> > "feather" <feather@discussions.microsoft.com> wrote in message
> > news:8AF4D029-B090-4B88-90BF-631C69E5CC59@microsoft.com...
> > > it's C# code, I am not sure if this is the right place...
> > > please let me know if there're somewhere else I can put this question
> > to...
> > >
> > > "feather" wrote:
> > >
> > > > my program worked fine with excel 2002, but when my user installed
an
> > old
> > > > excel version 2000 (i.e. the user has 2002 and 2000 on his pc now),
my
> > > > program throw exception when calling the open function...please
help...
> > > >
> > > > my code:
> > > >
> > > > oExlApp = new Excel.Application();
> > > > oExlApp.Visible = false;
> > > > oExlWB = (Excel._Workbook) oExlApp.Workbooks.Open(strSrcFileName,
> > > > Missing.Value, true, Missing.Value, Missing.Value,
Missing.Value,
> > > > Missing.Value, Missing.Value, Missing.Value, Missing.Value,
> > Missing.Value,
> > > > Missing.Value, Missing.Value, Missing.Value , Missing.Value);
> > > >
> >
> >
> >


Jon Peltier

12/20/2006 1:28:00 PM

0

I suspect the user erred in thinking he had to install 2000. There were
additions from 2000 to 2002, but I don't know of any lost functions.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
http://Pelti...
_______


"feather" <feather@discussions.microsoft.com> wrote in message
news:0482DF47-B354-4078-803B-2367F3AEC99B@microsoft.com...
> when I develop & deploy my program, the user have the same enviroment as
> me,
> only excel 2002. After a while, he installed 2000 to open some perticular
> xls
> file which have some function only available under 2000 (no idea what it
> is...). Anyway, that's why I got this issue.
>
> Yes I think late binding is a good idea, could you tell me how to do this
> in
> C#?
>
> Thanks a lot!
>
> "NickHK" wrote:
>
>> From what I understand about C# (not much), all arguments must be
>> included,
>> unlike VB/VBA where optional arguments can be omitted.
>> As the newer version has extra (optional) arguments compared to the older
>> version, these call will fail.
>> Maybe you need late binding and test the version of Excel to decide which
>> calls to make.
>>
>> But it is generally advised to develop on the oldest system you intend
>> support.
>>
>> NickHK
>>
>> "feather" <feather@discussions.microsoft.com> wrote in message
>> news:8AF4D029-B090-4B88-90BF-631C69E5CC59@microsoft.com...
>> > it's C# code, I am not sure if this is the right place...
>> > please let me know if there're somewhere else I can put this question
>> to...
>> >
>> > "feather" wrote:
>> >
>> > > my program worked fine with excel 2002, but when my user installed an
>> old
>> > > excel version 2000 (i.e. the user has 2002 and 2000 on his pc now),
>> > > my
>> > > program throw exception when calling the open function...please
>> > > help...
>> > >
>> > > my code:
>> > >
>> > > oExlApp = new Excel.Application();
>> > > oExlApp.Visible = false;
>> > > oExlWB = (Excel._Workbook) oExlApp.Workbooks.Open(strSrcFileName,
>> > > Missing.Value, true, Missing.Value, Missing.Value, Missing.Value,
>> > > Missing.Value, Missing.Value, Missing.Value, Missing.Value,
>> Missing.Value,
>> > > Missing.Value, Missing.Value, Missing.Value , Missing.Value);
>> > >
>>
>>
>>