From: Excel11 typelib gen''''ing wrong functio on
actually, the app i wrote did exactly that...but i wrote it in the late 90's
with a down-levelled version of Excel. "they" made a few changes...and
documentation wasn't one of them.

if/when i get this working, i'll post something here. thanks!

"danAutodesk" wrote:

> Hi -
>
> I finally gave up; wasn't able to get it working and had to move on... for
> now anyway. But eventually (and unfortunately) I will have to
> programmatically read from an Excel spreadsheet.
>
> One difference in your code is you've used rename(...) quite a lot. If I
> can get some time to investigate that, I will do so and respond to this
> thread.
>
> But it feels like we may "barking up the wrong tree," so to speak. The fact
> that there is no current documentation, and only 2 people who've even tried
> this does not sound promising.
>
> Maybe there is some more direct db connect method. In the fullness of time,
> I'll look into that as well.
>
> dan
>
> "Excel11 typelib gen''ing wrong functions" wrote:
>
> > Dan -- i'm running into the same thing you did. namely the examples i find on
> > MSDN are (possibly) for an older version of excel, therefore do not work for
> > Excel 2003. i've tried to follow your code snippets, but choke on the
> > following line...
> >
> > ExcelParameter excelParam = oWorkbooks.get__Default(COleVariant((short)2));
> >
> > i have
> >
> > #import "C:\\Program Files\\Common Files\\Microsoft
> > Shared\\OFFICE11\\MSO.DLL" \
> > rename("RGB", "ExclRGB") \
> > rename("DocumentProperties", "ExclDocumentProperties") \
> > rename("SearchPath", "ExclSearchPath")
> > #import "C:\\Program Files\\Common Files\\Microsoft
> > Shared\\VBA\\VBA6\\VBE6EXT.OLB"
> > #import "C:\\Program Files\\Microsoft Office\\OFFICE11\\EXCEL.EXE" \
> > rename("DialogBox", "ExclDialogBox") \
> > rename("RGB", "ExclRGB") \
> > rename("CopyFile", "ExclCopyFile") \
> > rename("ReplaceText", "ExclReplaceText") \
> > rename("Font", "ExcelFont") \
> > rename("Parameter", "ExcelParameter") \
> > rename("DocumentProperties", "ExcelDocumentProperties") \
> > rename("ExitWindows", "ExcelExitWindows") \
> > rename("Rectangle", "ExcelRectangle") \
> > rename("Arc", "ExcelArc") \
> > rename("Picture", "ExcelPicture")
> >
> > (note the "rename" for Parameter to ExcelParameter). however when i run my
> > code, it fails with a -2147352567 in oleDisp2.cpp on the following line...
> >
> > SCODE sc = m_lpDispatch->Invoke(dwDispID, IID_NULL, 0, wFlags, &dispparams,
> > pvarResult, &excepInfo, &nArgErr);
> >
> > what did you do differently that i'm not seeing?? tia!
> >
> >
> > "danAutodesk" wrote:
> >
> > > Thanks for your pointer. Alas it turns out at least a few of these articles
> > > are the same ones I was able to Google. I can't get past the application
> > > initialization. As such, I have a few more questions. I appologize in
> > > advance for the length of this message (brevity is scarce in code
> > > descriptions! ;-).
> > >
> > > ---
> > > 1. When I add any Excel object through the class / type lib wizard, a
> > > header is generated for the selected object. That part works fine. At the
> > > top of each header is the following code:
> > > #import "C:\\Program Files\\Microsoft Office\\OFFICE11\\EXCEL.EXE"
> > > no_namespace
> > >
> > > When I #include this header in my project, the compiler doesn't like the
> > > #import; warns of duplicate macro definitions and automatic exclusions. More
> > > importantly, the compiler throws errors becasue of redefinitions in the
> > > generated excel.tlh file.
> > >
> > > ---
> > >
> > > 2. Some imported Excel objects (such as, but definitely not limited to
> > > Workbooks.h) that contain method signatures suchs as the ones below:
> > > Application get_Application()
> > > {
> > > Application result;
> > > ...
> > > XlCreator get_Creator()
> > >
> > > These method signatures can't possibly work since the return types don't
> > > exist. It's easy enough to fix these signatures so things compile.
> > > Moreover, the code *seems* to run, but I don't know what is going on under
> > > the covers at all.
> > >
> > > ---
> > >
> > > There are several other issues like these that make me wonder whether I'm
> > > dealing with bugs, or whether c++ developers are just supposed to get through
> > > this with Excel.
> > >
> > > I understand c++ developers are a little more wiling to endure difficulty.
> > > That's why I was hoping there was some documentation on these APIs. Bumping
> > > around in the dark is a losing proposition.
> > >
> > > Finally, all the examples posted on the side you referenced look like they
> > > were made with older versions of Excel. The object signatures are no longer
> > > relevant. For example one example indicates: oBook =
> > > oBooks.Add(covOptional); but the signature for this method in the generated
> > > class (Excel 2003) is: (Add)(LPCTSTR Name, VARIANT& iDataType, Parameter * *
> > > RHS)
> > >
> > > There are no optional parameters apparently, and with no documentation on
> > > type values, Parameter or the RHS macro, it's very difficult to know where to
> > > go from here.
> > >
> > > Again, I apologize for the length of this post. If you've gotten this far,
> > > I thank you very much, and thank you even more for any and all assistance you
> > > can provide.
> > >
> > > dan
> > >
> > > "Tom Ogilvy" wrote:
> > >
> > > > go to
> > > > http://support.microsoft.com
> > > >
> > > > go to advanced search and search on C++ and Excel
> > > >
> > > > --
> > > > Regards,
> > > > Tom Ogilvy
> > > >
> > > >
> > > > "danAutodesk" wrote:
> > > >
> > > > > I have been looking for documentation - any documentation or better yet, real
> > > > > code examples regarding the c++ objects and methods for excel 2003. My
> > > > > progress has been based on reverse engineering and guessing so is quite slow.
> > > > > Help!
> > > > >
> > > > > My purpose is exceptionally simple, to read (only, not write or format) data
> > > > > from excel workbooks/worksheets.
> > > > >
> > > > > I have a c++ MFC DLL project and have created excel classes from the type
> > > > > library (actually .../EXCEL.EXE). The trouble really starts there - the
> > > > > imported classes won't compil
From: Excel11 typelib gen''''ing wrong functio on
well, i got it to add a workbook...AND generate an error in doing so (but at
least it's there). i overrode WorkBooks.Add(p1, p2, p3, p4) with

STDMETHOD(Add)() // added 7/19/06 dhm
{
HRESULT result;
InvokeHelper(0xb5, DISPATCH_METHOD, VT_HRESULT, (void*)&result, NULL);
return result;
}

so now i call: Workbooks.Add(); and a new Workbook appears. it also
generates an exception saying "bad variable type".

hey, it's a start.

"Excel11 typelib gen''''ing wrong functio" wrote:

> actually, the app i wrote did exactly that...but i wrote it in the late 90's
> with a down-levelled version of Excel. "they" made a few changes...and
> documentation wasn't one of them.
>
> if/when i get this working, i'll post something here. thanks!
>
> "danAutodesk" wrote:
>
> > Hi -
> >
> > I finally gave up; wasn't able to get it working and had to move on... for
> > now anyway. But eventually (and unfortunately) I will have to
> > programmatically read from an Excel spreadsheet.
> >
> > One difference in your code is you've used rename(...) quite a lot. If I
> > can get some time to investigate that, I will do so and respond to this
> > thread.
> >
> > But it feels like we may "barking up the wrong tree," so to speak. The fact
> > that there is no current documentation, and only 2 people who've even tried
> > this does not sound promising.
> >
> > Maybe there is some more direct db connect method. In the fullness of time,
> > I'll look into that as well.
> >
> > dan
> >
> > "Excel11 typelib gen''ing wrong functions" wrote:
> >
> > > Dan -- i'm running into the same thing you did. namely the examples i find on
> > > MSDN are (possibly) for an older version of excel, therefore do not work for
> > > Excel 2003. i've tried to follow your code snippets, but choke on the
> > > following line...
> > >
> > > ExcelParameter excelParam = oWorkbooks.get__Default(COleVariant((short)2));
> > >
> > > i have
> > >
> > > #import "C:\\Program Files\\Common Files\\Microsoft
> > > Shared\\OFFICE11\\MSO.DLL" \
> > > rename("RGB", "ExclRGB") \
> > > rename("DocumentProperties", "ExclDocumentProperties") \
> > > rename("SearchPath", "ExclSearchPath")
> > > #import "C:\\Program Files\\Common Files\\Microsoft
> > > Shared\\VBA\\VBA6\\VBE6EXT.OLB"
> > > #import "C:\\Program Files\\Microsoft Office\\OFFICE11\\EXCEL.EXE" \
> > > rename("DialogBox", "ExclDialogBox") \
> > > rename("RGB", "ExclRGB") \
> > > rename("CopyFile", "ExclCopyFile") \
> > > rename("ReplaceText", "ExclReplaceText") \
> > > rename("Font", "ExcelFont") \
> > > rename("Parameter", "ExcelParameter") \
> > > rename("DocumentProperties", "ExcelDocumentProperties") \
> > > rename("ExitWindows", "ExcelExitWindows") \
> > > rename("Rectangle", "ExcelRectangle") \
> > > rename("Arc", "ExcelArc") \
> > > rename("Picture", "ExcelPicture")
> > >
> > > (note the "rename" for Parameter to ExcelParameter). however when i run my
> > > code, it fails with a -2147352567 in oleDisp2.cpp on the following line...
> > >
> > > SCODE sc = m_lpDispatch->Invoke(dwDispID, IID_NULL, 0, wFlags, &dispparams,
> > > pvarResult, &excepInfo, &nArgErr);
> > >
> > > what did you do differently that i'm not seeing?? tia!
> > >
> > >
> > > "danAutodesk" wrote:
> > >
> > > > Thanks for your pointer. Alas it turns out at least a few of these articles
> > > > are the same ones I was able to Google. I can't get past the application
> > > > initialization. As such, I have a few more questions. I appologize in
> > > > advance for the length of this message (brevity is scarce in code
> > > > descriptions! ;-).
> > > >
> > > > ---
> > > > 1. When I add any Excel object through the class / type lib wizard, a
> > > > header is generated for the selected object. That part works fine. At the
> > > > top of each header is the following code:
> > > > #import "C:\\Program Files\\Microsoft Office\\OFFICE11\\EXCEL.EXE"
> > > > no_namespace
> > > >
> > > > When I #include this header in my project, the compiler doesn't like the
> > > > #import; warns of duplicate macro definitions and automatic exclusions. More
> > > > importantly, the compiler throws errors becasue of redefinitions in the
> > > > generated excel.tlh file.
> > > >
> > > > ---
> > > >
> > > > 2. Some imported Excel objects (such as, but definitely not limited to
> > > > Workbooks.h) that contain method signatures suchs as the ones below:
> > > > Application get_Application()
> > > > {
> > > > Application result;
> > > > ...
> > > > XlCreator get_Creator()
> > > >
> > > > These method signatures can't possibly work since the return types don't
> > > > exist. It's easy enough to fix these signatures so things compile.
> > > > Moreover, the code *seems* to run, but I don't know what is going on under
> > > > the covers at all.
> > > >
> > > > ---
> > > >
> > > > There are several other issues like these that make me wonder whether I'm
> > > > dealing with bugs, or whether c++ developers are just supposed to get through
> > > > this with Excel.
> > > >
> > > > I understand c++ developers are a little more wiling to endure difficulty.
> > > > That's why I was hoping there was some documentation on these APIs. Bumping
> > > > around in the dark is a losing proposition.
> > > >
> > > > Finally, all the examples posted on the side you referenced look like they
> > > > were made with older versions of Excel. The object signatures are no longer
> > > > relevant. For example one example indicates: oBook =
> > > > oBooks.Add(covOptional); but the signature for this method in the generated
> > > > class (Excel 2003) is: (Add)(LPCTSTR Name, VARIANT& iDataType, Parameter * *
> > > > RHS)
> > > >
> > > > There are no optional parameters apparently, and with no documentation on
> > > > type values, Parameter or the RHS macro, it's very difficult to know where to
> > > > go from here.
> > > >
> > > > Again, I apologize for the length of this post. If you've gotten this far,
> > > > I thank you very much, and thank you even more for any and all assistance you
> > > > can provide.
> > > >
> > > > dan
> > > >
> > > > "Tom Ogilvy" wrote:
> > > >
> > > > > go to
> > > > > http://support.microsoft.com
> > > > >
> > > > > go to advanced search and search on C++ a