Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Office Automation of a specific version 1

Status
Not open for further replies.

JackTheC

Programmer
Feb 25, 2002
324
NL
I have 2 versions of MS Office installed.
When I use createobject("excel.application") the last version is opened.
But I want the previous version to be used for Automation.
How to specify the version of Excel (or Word) to be used for Automation?

When I uninstall the last version, the previous becomes the active one again, but I want to be able to manually use both versions.
 
What's still an open question to me is why the CLSID of Excel.Application is constant: {000208D5-0000-0000-C000-000000000046}.
Could be some dependency that makes this necessary, or does it stste a commitment to compatibility?

One thing that must change per version is saving Workbooks with the dafult code Workbookobjedct.SaveAs(Filename). There are further parameters, all optional. The second is about the fileformat to use and the default is the current Excel version. If you save a file for working with it on the basis of expecting the old XLS binary format, that makes every newer version incompatible for that use case. So there's a simple case for how that commitment to compatibility is broken. Which I guess means it is not the reason of keeping the CLSID constant. On the opther side it's also an example of how differently you can argue what instates compatibility, always saving with the current format is a straight forward decision and understandbly better - if you drive it to the extreme: Should all Excel automatin code always output Excel 1.0 files? Of course not.

On the other hand, you can always adapt your Excel automation code to work with any Excel version with only a minimum requirement. For the sample case of SaveAs, you can pass in the Excel constant for a specific Excel version file, then that also works in the original lowest version number for which the code was programmed and can keep working.

Chriss
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top