Getting round the binding / different versions problem

D

David Macdonald

There seem to be quite a few posts about trying to get Word and Excel to work
together when the original files have been compiled in Office 2003 and users
have an older version. I have the same problem.
I'm sending from a Word form to Excel and getting other data back from the
same worksheet.
If I remove references to the Excel library I get errors (on other PCs)
because bits of the code aren't recognised by that version of Excel.
I thought a solution could be simply to have the Excel part of the code as a
macro in that sheet. All Word has to do is open the sheet and say
'Application.Run "macro"' but that doesn't work either. Is there a way to run
an excel macro from Word or am I coming up against the same incompatibility
of versions ?
 
C

Cindy M.

Hi =?Utf-8?B?RGF2aWQgTWFjZG9uYWxk?=,
There seem to be quite a few posts about trying to get Word and Excel to work
together when the original files have been compiled in Office 2003 and users
have an older version. I have the same problem.
I'm sending from a Word form to Excel and getting other data back from the
same worksheet.
If I remove references to the Excel library I get errors (on other PCs)
because bits of the code aren't recognised by that version of Excel.
I thought a solution could be simply to have the Excel part of the code as a
macro in that sheet. All Word has to do is open the sheet and say
'Application.Run "macro"' but that doesn't work either. Is there a way to run
an excel macro from Word or am I coming up against the same incompatibility
of versions ?
Application.Run should work. Since you don't describe how it doesn't for you,
that's difficult to trouble-shoot. But from experience I advise you to try all
the variations on how to specify the macro (file name, module name, etc.) And to
ask in the excel.programming newsgroup for help on that.

Another way to approach your problem, though, would be to test the version of
Excel you've hooked into and branch the code accordingly (If or Select Case).
Then use late-binding to address the object model, using only code that's
appropriate to the individual version. Late-binding means you declare all Excel
variables as Object (Dim wb as Object 'not Excel.Workbook) and remove the
reference to Excel from the project.

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 :)
 

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