[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

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

Posted on 2009-07-13
6
Medium Priority
?
543 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
Industry Leaders: 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: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses

649 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