|
-
Jan 24th, 2005, 07:15 AM
#1
Thread Starter
Junior Member
Dynamic Referense [RESOLVED]
Hi,
is there a way to dynamically referense an Excel object into my project according to the version of the MS office the target machine uses ?
My production pc uses Office 2003 whereas target machines might use Offiice 2000 or Office XP...
Thanks
Last edited by sonaht; Jan 24th, 2005 at 09:19 AM.
Even Angels Fall.....
-
Jan 24th, 2005, 08:03 AM
#2
Re: Dynamic Referense
Whatever object library is available to you from your references selection will be what version you will be able to use in your application.
If you are using Office 2003, there should be backward compatibility with lower versions. Have you tried running your app on a 2000 box or XP yet to see if you do have a problem? (your original post did not specifically say that you are running into issues. The inference from your question is that you believe you might.)
-
Jan 24th, 2005, 08:06 AM
#3
Re: Dynamic Referense
Yes, there are a few things to change in your code:
* The first is to replace the Excel types with Object, so if you have:
VB Code:
Dim xlApp as Excel.Application
Dim xlBook as Excel.Workbook
...
you need to change it to:
VB Code:
Dim xlApp as Object
Dim xlBook as Object
...
* The next change is to replace the initialisation of the object, so if you have:
VB Code:
Set xlApp = New Excel.Application
you should replace it with:
VB Code:
Set xlApp = CreateObject("Excel.Application")
* Remove "Excel object Library" from the list in Project References
* The final change is to replace any constants from the Excel library, or define them in your code (there is download at www.msdn.microsoft.com called wc0993.exe that has a module with them all defined, which you can simply add to your project).
-
Jan 24th, 2005, 08:06 AM
#4
Thread Starter
Junior Member
Re: Dynamic Referense
U are absolutely spot on.
I think i might have problems.... that'w why I asked..
I will try to compile using Office 2000 reference and see if there is a problem with later versions.
I just wanted to know if someone knew something on the matter...
thanks
-
Jan 24th, 2005, 08:08 AM
#5
Thread Starter
Junior Member
Re: Dynamic Referense
si_the_geek I will try that ......
it looks exectly what i was after .....
thanks
-
Jan 24th, 2005, 08:11 AM
#6
Re: Dynamic Referense
 Originally Posted by Hack
Whatever object library is available to you from your references selection will be what version you will be able to use in your application.
If you are using Office 2003, there should be backward compatibility with lower versions.
Not quite true I'm afraid, there were some changes in Office 2003 which mean initiating the object for earlier versions has some major issues, however once that is done almost everything seems ok.
Using my method means that whatever version is installed (95/97 and up) can be used without any change to the code (of course any features added to Office XP will fail if you try them on Office 97).
-
Jan 24th, 2005, 08:29 AM
#7
Re: Dynamic Referense
 Originally Posted by Hack
Originally Posted by Hack
Whatever object library is available to you from your references selection will be what version you will be able to use in your application.
If you are using Office 2003, there should be backward compatibility with lower versions.
 Originally Posted by si_the_geek
Not quite true I'm afraid, there were some changes in Office 2003 which mean initiating the object for earlier versions has some major issues, however once that is done almost everything seems ok.
Thanks for the info si, it has been awhile since I've done anything with any of the office products. I'm not running 2003. We still have the Office 2002 product suite. Were the changes you referenced first introduced in 2003, or might they be present in 2002 as well?
-
Jan 24th, 2005, 08:35 AM
#8
Re: Dynamic Referense
erm.. I can't remember, it hasn't been an issue for me as I have never been able to guarantee my users will have exactly the same versions (and don't want to re-compile a load of programs each time we upgrade anyway ), so I've always used the method above.
I'm pretty sure that the issue can be spotted by the item that is added to an installation package, if there is "Excel.exe" (rather than a tlb) the issue arises.
I would recommend always using the method I posted, as it allows unexpected changes to occur in the installation base without effecting your programs
-
Jan 24th, 2005, 08:41 AM
#9
Re: Dynamic Referense
 Originally Posted by si_the_geek
erm.. I can't remember, it hasn't been an issue for me as I have never been able to guarantee my users will have exactly the same versions (and don't want to re-compile a load of programs each time we upgrade anyway  ), so I've always used the method above.
I'm pretty sure that the issue can be spotted by the item that is added to an installation package, if there is "Excel.exe" (rather than a tlb) the issue arises.
I would recommend always using the method I posted, as it allows unexpected changes to occur in the installation base without effecting your programs 
Excellent advice!! (Who says you can't teach an old Hack new tricks! )
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|