excel ole automation c++

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)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#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();

	 }
Move this to the Windows section. It will be more visible to the those of us that have experience with WMI (I am one of them).
Topic archived. No new replies allowed.