Open Excel workbook. VB and VC

K

k-w

Hi all

In vb I do:


Dim Ex As New Excel.Application
Ex.Workbooks.Open "c:\tmp\Book1.xls"


Similar code in VC doesn't work:


#pragma comment(lib, "ole32.lib")
#import "c:\program files\Microsoft Office\OFFICE11\XL5EN32.OLB"
rename("DialogBox","__AA__")


/* ... */


Excel::ApplicationPtr app(L"Excel.Application");
((Excel::WorkbooksPtr)app->Workbooks())->Open(_variant_t("c:\\tmp\\Book1.xl­s"));



Index is wrong - yes because we didn't open Workbook yet


How to eliminate/fix/bypass this error


Or may be it should be different way to open Excel workbook in VC?


Best regards,
Vasiliy
 

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