用VC编一个程序,怎样让我的程序连接上word??
如能提供一个示例的程序,100分相送..谢谢!

解决方案 »

  1.   

    http://www.vckbase.com/document/viewdoc/?id=832http://www.vckbase.com/document/finddoc.asp?keyword=word
      

  2.   

    MSDN中有
    How To Attach to a Running Instance of an Office Application
    Automation servers register themselves in the Running Object Table (ROT) through the RegisterActiveObject() API. Automation clients can attach to a running instance with code such as the following:      ::CoInitialize(NULL);      // Translate server ProgID into a CLSID. ClsidFromProgID
          // gets this information from the registry.
          CLSID clsid;
          CLSIDFromProgID(L"Excel.Application", &clsid);        // Get an interface to the running instance, if any..
          IUnknown *pUnk;
          HRESULT hr = GetActiveObject(clsid, NULL, (IUnknown**)&pUnk);
          ASSERT(!FAILED(hr));      // Get IDispatch interface for Automation...
          IDispatch *pDisp;
          hr = pUnk->QueryInterface(IID_IDispatch, (void **)&pDisp);
          ASSERT(!FAILED(hr));      // Release the no-longer-needed IUnknown...
          pUnk->Release();     // ----------------------------------------------------
         // Your automation code here-
         // ----------------------------------------------------     ::CoUnintialize();