.NET Win Forms Application to Excel 2002, Excel 2003, and Excel 20

M

MaxGruven

Is it possible to access all 3 object models from C# or VB.NET?

My dot net Windows Forms application needs to be able to open an Excel file,
modify it and then save it. The application is .NET and will probably be
implemented in either C# or VB.NET and needs to supports users who might have
one of 3 different version of Excel on their machine:

- Excel 2002
- Excel 2003
- Excel 2007

Any guidance on how this can be accomplished?

Thanks in advance,
George

(BTW: This is a repost: my original apparently didn't not have my
posting-alias set up in my profile)
 
J

Jialiang Ge [MSFT]

Hello George,

Welcome to Microsoft Managed Newsgroup Support Service! My name is Jialiang
Ge, from Microsoft Managed Newsgroup support team.

From your post, my understanding on this issue is: you wonder how to write
automation clients in C# or VB.NET for multiple Office versions (e.g. Excel
2002, 2003, 2007), so that our client application (the winform) can
supports users who might have one of the 3 different version of Office. If
I'm off base, please feel free to let me know.

According to the KB article http://support.microsoft.com/kb/244167/EN-US/,
there are two approaches that we can accomplish the task:

1. If we are using "early binding", namely, directly referencing an Office
interop assembly in the application, we can reference the interop assembly
of the earliest version of the Office application we intend to automate.
This is called "backward compatibility". In this case, we can reference
"Microsoft Excel 10.0 Object Library" which is for Excel 2002. One drawback
of this approach is that it does not allow our automation client to use
functionality in a new version of Office (e.g. the new function "Export to
PDF" which is only available to Office 2007). If we do need to use
functionality in a newer version of Office, but we are developing a project
that must work on systems that contain more than one version, we should use
late binding to make the call (see approach 2).

2. We can use late binding. If we intend to use Late binding, I'd
personally suggest writing code with VB.NET. VB.NET provides a much easier
interface for late binding than C#.

For more details about the two approaches, please read the KB article
http://support.microsoft.com/kb/244167/EN-US/.
About early binding and late binding, we can refer to
http://support.microsoft.com/kb/245115/

Please let me know if you have any other concerns, or need anything else. I
will be more than happy to be of assistance.

Regards,
Jialiang Ge ([email protected], remove 'online.')
Microsoft Online Community Support

==================================================
For MSDN subscribers whose posts are left unanswered, please check this
document: http://blogs.msdn.com/msdnts/pages/postingAlias.aspx

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications. If you are using Outlook Express/Windows Mail, please make sure
you clear the check box "Tools/Options/Read: Get 300 headers at a time" to
see your reply promptly.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
M

MaxGruven

That's it exactly!

Thanks,
Jialiang

Jialiang Ge said:
Hello George,

Welcome to Microsoft Managed Newsgroup Support Service! My name is Jialiang
Ge, from Microsoft Managed Newsgroup support team.

From your post, my understanding on this issue is: you wonder how to write
automation clients in C# or VB.NET for multiple Office versions (e.g. Excel
2002, 2003, 2007), so that our client application (the winform) can
supports users who might have one of the 3 different version of Office. If
I'm off base, please feel free to let me know.

According to the KB article http://support.microsoft.com/kb/244167/EN-US/,
there are two approaches that we can accomplish the task:

1. If we are using "early binding", namely, directly referencing an Office
interop assembly in the application, we can reference the interop assembly
of the earliest version of the Office application we intend to automate.
This is called "backward compatibility". In this case, we can reference
"Microsoft Excel 10.0 Object Library" which is for Excel 2002. One drawback
of this approach is that it does not allow our automation client to use
functionality in a new version of Office (e.g. the new function "Export to
PDF" which is only available to Office 2007). If we do need to use
functionality in a newer version of Office, but we are developing a project
that must work on systems that contain more than one version, we should use
late binding to make the call (see approach 2).

2. We can use late binding. If we intend to use Late binding, I'd
personally suggest writing code with VB.NET. VB.NET provides a much easier
interface for late binding than C#.

For more details about the two approaches, please read the KB article
http://support.microsoft.com/kb/244167/EN-US/.
About early binding and late binding, we can refer to
http://support.microsoft.com/kb/245115/

Please let me know if you have any other concerns, or need anything else. I
will be more than happy to be of assistance.

Regards,
Jialiang Ge ([email protected], remove 'online.')
Microsoft Online Community Support

==================================================
For MSDN subscribers whose posts are left unanswered, please check this
document: http://blogs.msdn.com/msdnts/pages/postingAlias.aspx

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications. If you are using Outlook Express/Windows Mail, please make sure
you clear the check box "Tools/Options/Read: Get 300 headers at a time" to
see your reply promptly.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
J

Jialiang Ge [MSFT]

You are welcome. It's my pleasure to be of assistance. : )

Jialiang Ge ([email protected], remove 'online.')
Microsoft Online Community Support

==================================================
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

This posting is provided "AS IS" with no warranties, and confers no rights.
==================================================
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top