excel ole automation c++
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: excel ole automation c++

  1. #1
    Join Date
    Sep 2013
    Posts
    10

    excel ole automation c++

    hello,

    im 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();
    
    	 }

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,360

    Re: excel ole automation c++

    Victor Nijegorodov

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center