TAILIEUCHUNG - Excel Add-in Development in C/C++ Applications in Finance phần 9

Tham khảo tài liệu 'excel add-in development in c/c++ applications in finance phần 9', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | Miscellaneous Topics 299 The following code shows how these steps can be accomplished void UninitExcelOLE void _ Release the IDispatch pointer. This will decrement its RefCount pExcelDisp- Release pExcelDisp NULL Good practice OleUninitialize Once this is done the Excel application s methods and properties can fairly straightforwardly be accessed as demonstrated in the following sections. Note that access to Excel s worksheet functions for example requires the getting of the worksheet functions interface something that is beyond the scope of this book. Getting Excel to recalculate worksheets using COM This is achieved using the Calculate method exposed by Excel via the COM interface. Once the above initialisation of the pExcelDisp IDispatch object has taken place the following code will have the equivalent effect of the user pressing the F9 key. Note that the call to the GetIDsOfNames method is executed only once for the Calculate command greatly speeding up subsequent calls. HRESULT OLE_ExcelCalculate void if pExcelDisp return S_FALSE static DISPID dispid 0 DISPPARAMS Params char cErr 64 HRESULT hr DISPPARAMS has four members which should all be initialised NULL Dispatch IDs of named args NULL Array of arguments 0 Number of arguments 0 Number of named arguments Get the Calculate method s dispid if dispid 0 first call to this function GetIDsOfNames will only be called once. Dispid is cached since it is a static variable. Subsequent calls will be faster. wchar_t ucName L Calculate hr pExcelDisp- GetIDsOfNames IID_NULL ucName 1 LOCALE_SYSTEM_DEFAULT dispid if FAILED hr Perhaps VBA command or function does not exist sprintf cErr Error hr 0x 08lx hr MessageBox NULL cErr GetIDsOfNames 300 Excel Add-in Development in C C MB_OK MB_SETFOREGROUND return hr Call the Calculate method hr pExcelDisp- Invoke dispid IID_NULL LOCALE_SYSTEM_DEFAULT DISPATcH_METHOD Params NULL NULL NULL if FAILED hr Most .

Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.