Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Automation of Excell

Status
Not open for further replies.

reneb

Programmer
Aug 8, 2000
43
US
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(&quot;Excel.Application&quot;,0,CLSCTX_LOCAL_SERVER);
if(FAILED(hr))
{
MessageBox(0,&quot;&quot;,&quot;&quot;,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&quot;hello world&quot;));//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&quot;\x0008&quot;,SysAllocString(L&quot;hello&quot;));//input box
getch();
}
CoUninitialize();
return 0;
}
John Fill
1c.bmp


ivfmd@mail.md
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top