Click to See Complete Forum and Search --> : How to use OLE automation to open any version of Excel?
chinniwhites
July 19th, 2005, 06:00 PM
I have written a program that uses ole to open Excel 2003. I believe this is dependent on the microsoft.office.interop.excel.dll (version 11). How could I write my program to open excel regardless of version and/or dll?
Tom Frohman
July 20th, 2005, 07:57 AM
A couple of suggestions:
see
http://www.codeguru.com/forum/showthread.php?t=337068
1) rewrite the open function so it has a minimum number of arguments.
2) test for version of excel and use the version of open for that version
chinniwhites
July 20th, 2005, 10:23 AM
I looked at the example and have a few questions. First, do i have to still use the microsoft.office.interop.excel namespace at the top of my code? If not, how will the program know how to intepret the application.open, saveas, and other commands link to the microsoft.office.interop.excel.dll? If i do use it, isnt dependent of the version of the dll (2003 being version 11)?
chinniwhites
July 20th, 2005, 10:56 AM
Also, how would you test for the version of the Office application that you are using? How would I open excel 2000 with the excel 2003 dll or does it not matter?
Tom Frohman
July 20th, 2005, 01:04 PM
Also, how would you test for the version of the Office application that you are using? How would I open excel 2000 with the excel 2003 dll or does it not matter?
Well, the way I would do it was to rewrite the prototypes of the functions to use the minimum number of arguments. That way 1 version will work for all versions of office.
The test for version suggestion didn't come from me.
However, I've seen the suggestion several times in the past.
A couple of the ones I remembered
http://www.codeguru.com/forum/showthread.php?t=151437&highlight=office+namespace
http://www.codeguru.com/forum/showthread.php?t=332449&highlight=office+version
chinniwhites
July 20th, 2005, 03:32 PM
Ok. How do I rewrite the Open and SaveAs for the Microsoft Office Library 11.0 so I can open and saveas using any version of excel?
Tom Frohman
July 20th, 2005, 04:32 PM
I did this in the example sited above
http://www.codeguru.com/forum/showthread.php?t=337068
Here I go to the Class View and add a new class from a type library.
Then I overload the generated SaveAs method with the version in the example.
It will be in a different file than the one shown in the example because I did that with Visual C++ 6.0 and Excel 2000.
chinniwhites
July 20th, 2005, 04:37 PM
Would the code be the same?
codeguru.com
Copyright WebMediaBrands Inc., All Rights Reserved.