?
hi, so in etwa solltest du das hinbekommen
//oder wo auch immer in welchen verzeichnissen die exceldateien zu finden sind... die sind jetzt für office2000 wenn du ne aktuellere version hast oder ne ältere ist es dann ne z.b. ne 8 oder ne 10 statt der 9
#import <mso9.dll> no_namespace rename("DocumentProperties", "DocumentPropertiesXL")
//#import "C:\Program Files\Common Files\Microsoft Shared\VBA\VBA6\vbe6ext.olb" no_namespace
#import "C:\Programme\Gemeinsame Dateien\Microsoft Shared\VBA\VBA6\vbe6ext.olb" no_namespace
#import <excel9.olb> rename("DialogBox", "DialogBoxXL") rename("RGB", "RBGXL") rename("DocumentProperties", "DocumentPropertiesXL") no_dual_interfaces
void dump_com_error(_com_error &e)
{
_tprintf(_T("Oops - hit an error!\n"));
_tprintf(_T("\a\tCode = %08lx\n"), e.Error());
_tprintf(_T("\a\tCode meaning = %s\n"), e.ErrorMessage());
_bstr_t bstrSource(e.Source());
_bstr_t bstrDescription(e.Description());
_tprintf(_T("\a\tSource = %s\n"), (LPCTSTR) bstrSource);
_tprintf(_T("\a\tDescription = %s\n"), (LPCTSTR) bstrDescription);
}
struct StartOle {
StartOle() { CoInitialize(NULL); }
~StartOle() { CoUninitialize(); }
} _inst_StartOle;
using namespace Excel;
_ApplicationPtr pXL;
try {
if (pXL.GetInterfacePtr() == NULL) pXL.CreateInstance(L"Excel.Application.9"); //check ob es schon laeuft
pXL->Visible = VARIANT_FALSE; //oder halt true wenn mans sehen will
WorkbooksPtr pBooks;
_WorkbookPtr pBook;
WorksheetsPtr pSheets;
_WorksheetPtr pSheet;
pBooks = pXL->get_Workbooks();
pBook = pBooks->Open("c:\\tralala.xls");
double wert=pXL->Range["Blatt1!A5]->Value;
printf("Gelesener Wert aus zelle A5\n",wert);
} catch(_com_error &e){dump_com_error(e);}