Select the product you need help with
How to use MFC to automate Excel 2000 and Excel 2002 and obtain an array from a range in Excel 2000 and Excel 2002Article ID: 186122 - View products that this article applies to. This article was previously published under Q186122 On This PageSUMMARY This article demonstrates how to automate Microsoft Excel
and return the values from a multi-cell range to an array. MORE INFORMATION To return the values from a multi-cell range without
querying the cells one-by-one, you must use the GetValue member function of the
Range object to return the values to a VARIANT. You then construct a SAFEARRAY
based on the VARIANT you returned from GetValue. Once you have the SAFEARRAY,
you can access the elements using GetElement. The following steps illustrate
this process and demonstrate how you can access both string and numeric
elements. Notes for Automating Microsoft Excel 2000 and 2002The sample code in this article uses class wrappers generated from the Excel 97 object library (Excel 8.olb). With slight modification, this code can be applied to an Automation client that uses class wrappers for Excel 2000 (Excel9.olb) or Excel 2002 (Excel.olb). For additional information about using the sample code described in this article with the Microsoft Excel 2000 or 2002 type library, click the article number below to view the article in the Microsoft Knowledge Base:224925
(http://support.microsoft.com/kb/224925/EN-US/
)
INFO: Type Libraries for Office May Change with New Release
Steps to Create Project
REFERENCES For additional information about automating Microsoft Excel
using MFC, please click the article numbers below to view the articles in the
Microsoft Knowledge Base: 186120
(http://support.microsoft.com/kb/186120/EN-US/
)
How To Use MFC to Automate Excel and Fill a Range with an Array
184663
(http://support.microsoft.com/kb/184663/EN-US/
)
How To Embed and Automate a Microsoft Excel Worksheet with MFC179706
(http://support.microsoft.com/kb/179706/EN-US/
)
How To Use MFC to Automate Excel and Create/Format a New Workbook178781
(http://support.microsoft.com/kb/178781/EN-US/
)
HOWTO: Automate Excel Using MFC and Worksheet Functions178783
(http://support.microsoft.com/kb/178783/EN-US/
)
HOWTO: Use MFC to Create a Microsoft Excel Chart167668
(http://support.microsoft.com/kb/167668/EN-US/
)
How To Pass a SafeArray of Strings in a VARIANT*PropertiesArticle ID: 186122 - Last Review: January 23, 2007 - Revision: 5.1 APPLIES TO
| Article Translations
|


Back to the top








