Does anyone know of any reference to how to use the Automations of Excel in Visual C++. I am able to get the classes from the type def file and open excell from my program but some of the functions have complex parameters. Thanks in advance.
this is a full working ATL simple. Try it.
#include<iostream>
#include<atlbase.h>
#include<conio.h>
#include<comdef.h>
using namespace std;
int main()
{
CoInitialize(NULL);
{
CComPtr<IDispatch> pdExAp;
CComPtr<IUnknown> puExAp;
HRESULT hr;
hr=puExAp.CoCreateInstance("Excel.Application",0,CLSCTX_LOCAL_SERVER);
if(FAILED(hr))
{
MessageBox(0,"","",0);
}_variant_t x;
puExAp->QueryInterface(IID_IDispatch,(void**)&pdExAp);
_com_dispatch_propput(pdExAp,0x0000022e,VT_BOOL,1);//Visible
_com_dispatch_propput(pdExAp,0x0000008b,VT_BSTR,SysAllocString(L"hello world");//SetCaption
_com_dispatch_method(pdExAp,0x00000433,DISPATCH_METHOD,0,0,0);//GetOpenFileName
_com_dispatch_method(pdExAp,0x00000434,DISPATCH_METHOD,0,0,0);//GetSaveFileName
_com_dispatch_method(pdExAp,0x00000165,DISPATCH_METHOD,0,0,L"\x0008",SysAllocString(L"hello");//input box
getch();
}
CoUninitialize();
return 0;
} John Fill
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.