| CodeGuru Home | VC++ / MFC / C++ | .NET / C# | Visual Basic | Newsletters | VB Forums | Developer.com |
|
|||||||
| Managed C++ and C++/CLI Discuss Managed C++ and .NET-specific questions related to C++. |
![]() |
|
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
How to use OLE automation to open any version of Excel?
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?
|
|
#2
|
||||
|
||||
|
Re: How to use OLE automation to open any version of Excel?
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
__________________
Verere testudinem! (Fear the turtle) Once you can accept the universe as matter expanding into nothing that is something, wearing stripes with plaid comes easy. -Albert Einstein Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. -Cicero |
|
#3
|
|||
|
|||
|
Re: How to use OLE automation to open any version of Excel?
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)?
|
|
#4
|
|||
|
|||
|
Re: How to use OLE automation to open any version of Excel?
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?
|
|
#5
|
||||
|
||||
|
Re: How to use OLE automation to open any version of Excel?
Quote:
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/showth...fice+namespace http://www.codeguru.com/forum/showth...office+version
__________________
Verere testudinem! (Fear the turtle) Once you can accept the universe as matter expanding into nothing that is something, wearing stripes with plaid comes easy. -Albert Einstein Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. -Cicero |
|
#6
|
|||
|
|||
|
Re: How to use OLE automation to open any version of Excel?
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?
|
|
#7
|
||||
|
||||
|
Re: How to use OLE automation to open any version of Excel?
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.
__________________
Verere testudinem! (Fear the turtle) Once you can accept the universe as matter expanding into nothing that is something, wearing stripes with plaid comes easy. -Albert Einstein Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. -Cicero |
|
#8
|
|||
|
|||
|
Re: How to use OLE automation to open any version of Excel?
Would the code be the same?
|
![]() |
| Bookmarks |
|
||||||
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|