Article ID: 196776
Article Last Modified on 1/23/2007
152023 Locating Resources to Study OLE Automation
179706 HOWTO Use MFC to Automate Excel & Create/Format a New Workbook
181473 HOWTO: Use OLE Automation from a C Application
// 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();
NOTE: If there are multiple instances running of the Office application you want to attach, you will only be able to attach to the first instance that was launched using the GetActiveObject() API.190985 HOWTO: Get IDispatch of an Excel or Word Document From an OCX
// VARIANT used in place of optional-parameters.
VARIANT varOpt;
varOpt.vt = VT_ERROR;
varOpt.scode = DISP_E_PARAMNOTFOUND;
This is really what Visual Basic is doing behind-the-scenes.
183599 HOWTO: Catch Microsoft Word97 Application Events Using VC++
186120 HOWTO: Use MFC to Automate Excel and Fill a Range with an Array
186122 HOWTO: Use MFC to Automate Excel & Obtain an Array from a Range
179706 HOWTO: Use MFC to Automate Excel and Create/Format a New Workbook
186063 INFO: Translating Automation Errors for VB/VBA
122957 SAMPLE: Decode32 and Decode16 OLE Error Code Decoder Tools
Office Application | Type library
------------------------+----------------
Word 95 and prior | wb70en32.tlb
Excel 95 and prior | xl5en32.olb
Powerpoint 95 and prior | Powerpoint.tlb
Access 95 and prior | msaccess.tlb
Binder 95 | binder.tlb
Schedule+ | sp7en32.olb
Project | pj4en32.olb
Team Manager | mstmgr1.olb
Word 97 | msword8.olb
Excel 97 | excel8.olb
Powerpoint 97 | msppt8.olb
Access 97 | msacc8.olb
Binder 97 | msbdr8.olb
Graph 97 | graph8.olb
Outlook 97 | msoutl8.olb
Outlook 98 | msoutl85.olb
Word 2000 | msword9.olb
Excel 2000 | excel9.olb
Powerpoint 2000 | msppt9.olb
Access 2000 | msacc9.olb
Outlook 2000 | msoutl9.olb
Word 2002 | msword.olb
Excel 2002 | excel.exe
Powerpoint 2002 | msppt.olb
Access 2002 | msacc.olb
Outlook 2002 | msoutl.olb
172108 HOWTO: Troubleshooting "Member not found", 0x80020003 Error
184663 HOWTO: Embed and Automate a Microsoft Excel Worksheet With MFC
179494 HOWTO: Use Automation to Retrieve Built-In Document Properties
186898 HOWTO: Read Compound Document Properties Directly with VC++
Additional query words: coledispatchdriver colesafearray colevariant _com_ptr_t _com_variant_t IPropertySetStorage
Keywords: kbautomation kbfaq KB196776