vb office automation questions

H

Haris

Hi,

I am writing excel automation from vb at the moment, my question is can I
have more than 1 refference from vb, since my client is using different
version of office in their office.

if not, how do I write generic software to automate that target different
version of excel also moving forward how to support future office version?
is there any config file that I can change or add when office 2010 is
release instead of needing to go back to the code and add new reference then
rebuild and new installation to client just for the new office reference?

I appreciated if any body can shed some light on what's the best way to do
this, I'm still newbie in office automation thing.

Thanks in advance.

Regards
- Haris -
 
C

Cindy M.

Hi Haris,
I am writing excel automation from vb at the moment, my question is can I
have more than 1 refference from vb, since my client is using different
version of office in their office.

if not, how do I write generic software to automate that target different
version of excel also moving forward how to support future office version?
is there any config file that I can change or add when office 2010 is
release instead of needing to go back to the code and add new reference then
rebuild and new installation to client just for the new office reference?

I appreciated if any body can shed some light on what's the best way to do
this, I'm still newbie in office automation thing.

Well, the official MS line is that a user should have only one version of
Office installed, and you should compile a separate version of your application
for each version you intend to support.

Barring that, you do need to program against the *oldest* version you intend to
support. And you should explicitly use tlb.imp to create your own set of IAs in
your project folder. Your project should reference these, and the property to
create local copies should be activated so that you distribute them with your
application. IOW, your application would be dependent on your custom set of
Interop Assemblies, not the ones distributed by Microsoft.

The other option would be to use late-binding, rather than early-binding. (That
means declaring everything as an "Object", which means no Intellisense, and you
have to have Option Strict Off.)

In any case, you cannot avoid problems that may crop up if the object model
changes. (This was the case, for example, for parts the Charting engine going
from earlier versions to Office 2007.)

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail :)
 
F

filip

Hi,

I am writing excel automation from vb at the moment, my question is can I
have more than 1 refference from vb, since my client is using different
version of office in their office.

if not, how do I write generic software to automate that target different
version of excel also moving forward how to support future office version?
is there any config file that I can change or add when office 2010 is
release instead of needing to go back to the code and add new reference then
rebuild and new installation to client just for the new office reference?

I appreciated if any body can shed some light on what's the best way to do
this, I'm still newbie in office automation thing.

Thanks in advance.

Regards
- Haris -

Hi,

Excel Automation is not best way to work with Excel in VB. All users
that want to use your application must have identical version of Excel
that you have. If new version of Excel comes out, your program will
probably be obsolete. To avoid that you should use 3rd party
components which don't need user to have Excel installed so it doesn't
matter what version you have. You can try GemBox.Spreadsheet - .NET
component for Excel - component that makes it much easier to work with
Excel from .NET. Component is free for commercial use (limit of 150
rows).

http://www.gemboxsoftware.com/GBSpreadsheet.htm

Filip
 
A

Alan Moseley

Cindy

I agree whole-heartedly with you, I have created my own IAs based on Excel
2000 for my add-in, and it works quite nicely on the whole. I would have
preferred to use late-binding, as it seems to be the method recommended by
Microsoft(http://support.microsoft.com/kb/244167 and
http://support.microsoft.com/kb/245115/), and it is supposed to be marginally
faster. However I came up against a problem trying to capture an Excel
event. With early binding you just declare your object WithEvents. eg.

Dim WithEvents objWorkbook as Excel.Workbook

and then create a sub that handles a particular event eg.

Private Sub objWorkbook_SheetChange() Handles objWorkbook.SheetChange

How would one go about capturing events when using late-binding?

Haris

I hope you don't mind me tacking this question into your thread, but it may
well help you decide which route you should follow.
 

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