Second instance of OWC11 fails

V

vadimp1

Hello,
I need to create several instances of hidden Spreadsheet component in
C++ DLL. Following code works fine with OWC10, but fails on second and
folowing instances with OWC11:

CSpreadsheet book; /* COleDispatchDriver - derived class, created from
type library */
book.CreateDispatch( m_strOWCDispatch ); /* here string either
"OWC11.Spreadsheet.11" or "OWC10.Spreadsheet.10" */
book.m_bAutoRelease = FALSE;
....
book.DetachDispatch();
book.m_lpDispatch = NULL;

second CreateDispatch() causes access violation.

Any ideas why?

Thanks,
Vadim
 
A

Alvin Bruney - ASP.NET MVP

Why do you need several instances of excel? I'd assume that you need one
instance with possibly several books consisting of several sheets. That's
more than enough functionality for most real world scenarios.

--
Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The Microsoft Office Web Components Black Book with .NET
Now Available @ www.lulu.com/owc
Forth-coming VSTO.NET - Wrox/Wiley 2006
 
V

vadimp1

I would not mind your scenario but upon examining type library could
not find method to add workbook to spreadsheet. Workbooks interface has
only get methods and no Add or something similar.
 
A

Alvin Bruney - MVP ASP.NET

once you instantiate the excel object, it creates a workbook and 3
worksheets by default. You just need to iterate the collection of
worksheets. Hope that helps.

--
Regards,
Alvin Bruney

Shameless Author Plug
[The Microsoft Office Web Components Black Book with .NET]
www.lulu.com/owc, Amazon, Barnes & Noble etc
Forth-coming VSTO.NET
 
V

vadimp1

I am using worksheets in workbook already. That part works fine.
Unfortunately, one workbook is not enough for me. I have to have
several of them, and when I call code in my first post to create second
and following spreadsheet (in order to have more workbooks) it causes
access violation.
 

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