Solved

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

Posted on 2009-07-13
6
513 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:MisterT25
  • 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:MisterT25
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:MisterT25
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 500 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:MisterT25
ID: 31602856
I get it.  Thank very much for your help !
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

760 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now