?
Solved

VB.NET - How to support Excel 2003 and 2007 ?

Posted on 2009-07-13
6
Medium Priority
?
539 Views
Last Modified: 2012-05-07
I am using COM Interop with Excel to import a Tab delimited file and display the data.  This works with both Excel 2003 "OR" 2007.

I am referencing Office 11 library for Excel 2003 and Office 12 for 2007.

How can determine the version on the local PC and then reference the corresponding Office library?

Thanks for any ideas.
0
Comment
Question by:Tom Sage
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 5

Expert Comment

by:rizwanidrees
ID: 24840512
following code will work with all version and you will not need to add any reference

Dim XL as Object
Set XL = CreateObject("Excel.Application")
0
 

Author Comment

by:Tom Sage
ID: 24840786
I will try your suggestion and see if that works for me.

Thank you
0
 
LVL 41

Expert Comment

by:graye
ID: 24840826
You can check the registry for either the presence of the Office Primary Interop Assembiles (PIA) or for the Excel application itself
The keys to look for are at HKLM\SOFTWARE\Classes\CLSID

Primary interop assemblies for Office 2003:   {91490409-6000-11D3-8CFE-0150048383C9}

Primary interop assemblies for the 2007 release of Office:  {50120000-1105-0000-0000-0000000FF1CE}
 

Primary interop assembly       Office 2003 component ID               Office 2007 component ID 
Excel                    {A1FE0698-609D-400F-BF10-F52238DD6475}  {1ABEAF09-435F-47D6-9FEB-0AD05D4EF3EA} 
InfoPath                 {C1E59364-35F6-44B3-AF0F-FCA934C4B252}  {F1B5AE30-CB00-4DCF-978B-07D33B034ADB} 
Outlook                  {14D3E42A-A318-4D77-9895-A7EE585EFC3B}  {ED569DB3-58C4-4463-971F-4AAABB6440BD} 
PowerPoint               {3F40FA9E-26CA-4CA2-93C9-603622349915}  {04E73476-518E-4B6A-8E10-021A00078847} 
Visio                    {6F1AE751-4D8A-4B25-AC0A-C6CB912A9791}  {C1F1028F-D91A-43E8-A117-4F7CAFD7A041} 
Word                     {1C8772BD-6E6F-4C9D-8FF8-B5EA072F86EF}  {816D4DFD-FF7B-4C16-8943-EEB07DF989CB} 
Microsoft Forms 2.0*     {835AC3CE-E36B-4D65-B50F-2863A682ABEE}  {835AC3CE-E36B-4D65-B50F-2863A682ABEE} 
Microsoft Graph          {A58B51D1-89BF-4D88-939D-B6D0DB2EEB53}  {580CB155-841D-4D48-9F59-866A035C2241} 
Smart Tag                {53C65973-D89D-4EA0-8567-8788C14E0A02}  {00B41853-4377-4AD8-AD44-8404E0D331EC} 

Open in new window

0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:Tom Sage
ID: 24841027
Graye,

Once I check for the PIAs, what do I do next?  Should I use the PIA rather than adding a reference to the Excel object?

Thank you
0
 
LVL 41

Accepted Solution

by:
graye earned 2000 total points
ID: 24841327
Well, I'd recommend that you include both the 2003 and 2007 references in your application.... then at runtime, you'd check the registry on the client's PC to see what they've got, then you'd switch to that version.    Consider the following psuedo code
If registry.check(.....2007PIA) then
ex = new Excel2007
else
ex = new Execl2003
endif
0
 

Author Closing Comment

by:Tom Sage
ID: 31602856
I get it.  Thank very much for your help !
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses
Course of the Month14 days, 21 hours left to enroll

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question