ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   What's the equivalent way of "Cells" method for the C++(ATL) (https://www.excelbanter.com/excel-programming/284525-whats-equivalent-way-cells-method-c-atl.html)

David K. Kim

What's the equivalent way of "Cells" method for the C++(ATL)
 
As in VB's

MyWorksheet.Cells(2,3) = "Hello1"

If I wanna do this in VC++,
What's the equivalent way(using ATL).

More specifically,
I've downloaded the following code from a Web source.

.............
CoInitialize(NULL);

Excel::_ApplicationPtr excel;
HRESULT hr = excel.CreateInstance(L"Excel.Application");

Excel::_WorkbookPtr workbook =
excel-Workbooks-Add(static_cast<long(Excel::xlWorksheet));
Excel::_WorksheetPtr worksheet = excel-ActiveSheet;

worksheet-Range["A1"]-Value = "Hello1"; // Set a value

workbook-Close();
excel-Quit();
CoUninitialize();
........

In this source code,
How can I change this
worksheet-Range["A1"]-Value = "Hello1";
to the following way
worksheet-Cells ?

Thanks, In advance.



Bill Manville

What's the equivalent way of "Cells" method for the C++(ATL)
 
David K. Kim wrote:
In this source code,
How can I change this
worksheet-Range["A1"]-Value = "Hello1";
to the following way
worksheet-Cells ?

Thanks, In advance.


I guess nobody in this Excel newsgroup speaks C++ (including me).
But it would seem reasonable, by analogy, that

worksheet-Cells[2,3]-Value = "Hello1";

might work.

Bill Manville
MVP - Microsoft Excel, Oxford, England
No email replies please - reply in newsgroup



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

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