ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   COM automation in CPP question about array (https://www.excelbanter.com/excel-programming/337971-com-automation-cpp-question-about-array.html)

Nicolas[_2_]

COM automation in CPP question about array
 
Hi,

I want to do the following with automation :

* Get a cell that is containing a formula (let's call it A1).
* Resize the range to be 5 by 5
* Enter a new formula in A1 that will be an array function and output in the
new range.

I did the following :

Range range = m_pExcelApplication.GetActiveCell();
if(range != NULL)
{
Range resizedRange =
range.GetResize(_variant_t((long)5),_variant_t((lo ng)5));

lColumn = formulaRange.GetColumn();
lRow = formulaRange.GetRow();
tmp.Format("column : %u, row : %u", lColumn, lRow);
OutputDebugString(tmp); //give me "column : 5, row : 5"
resizedRange.Select();
formulaRange.SetFormulaArray(_variant_t("=myNewFor mula"));
}

But it doesn't work.
I always get the "Unable to set the FormulaArray property of the Range
class" error.

Can anybody help me?

Thanks

Nic




All times are GMT +1. The time now is 06:04 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com