hello,
i´m new in C++.
i need to make a programm to write in a excell cell a number.
i must use OLE Automation.
can you help me?? how i can do it??
thank you
i have made: (may be i have some mistakes)
Code:
#include "stdafx.h"
#include <stdio.h>
#include <windows.h>
#include <ole2.h>
#include <assert.h>
#include <iostream>
void main(void) {
CLSID clsid;
CLSIDFromProgID(L"Excel.Application", &clsid);
IUnknown *pUnk;
HRESULT hr = GetActiveObject(clsid, NULL, (IUnknown**)&pUnk);
assert(!FAILED(hr));
IDispatch *pDisp;
hr = pUnk->QueryInterface(IID_IDispatch, (void **)&pDisp);
assert(!FAILED(hr));
if (!pDisp) {
MessageBoxA(NULL, "Failed to find instance!!", "Error", MB_ICONHAND);
}
else {
MessageBoxA(NULL, "Got instance of Excel!", "Success", MB_OK);
}
if (pUnk)
pUnk->Release();
//here i want to write a number in a cell
if (pDisp)
pDisp->Release();
CoUninitialize();
}