我在VC里嵌入的Excel,当鼠标选中单元格时,如何得到选中的起始行列?POSITION_INFO ob;//存储起始行列的自定义结构
IDispatch* pIDispatch;

_Workbook workbook;
_Worksheet worksheet;
Range range,Cell;pIDispatch = g_pCntrItem->GetIDispatch();
workbook.AttachDispatch(pIDispatch);
worksheet = workbook.GetActiveSheet();
range = worksheet.GetUsedRange();

Cell = range.GetColumns();
ob.icol = Cell.GetColumn();
ob.icolc = Cell.GetCount();

Cell = range.GetRows();
ob.irow = Cell.GetRow();
ob.irowc = Cell.GetCount(); 为什么得到的结果都是1??该怎么做啊????????????????????????

解决方案 »

  1.   

    看看这个帖子里我的代码对你是否有用:
    http://community.csdn.net/Expert/topic/3220/3220812.xml?temp=.830929
      

  2.   

    liuxianzhi(碧渊),那个帖子没什么帮助。
    没人会吗????
      

  3.   

    http://www.vckbase.com/document/viewdoc/?id=231看看这里,是否有你要的?
      

  4.   

    IDispatch* pIDispatch;
    _Application app;
    _Workbook workbook;
    _Worksheet worksheet;
    Range range,Cell;workbook.AttachDispatch(pIDispatch);
    worksheet = workbook.GetActiveSheet();
    app =workbook.GetApplication();
    range.AttachDispatch(app.GetSelection()); 
    Storm 01:47:44
    Cell = range.GetRows();
    irow = Cell.GetRow();
    irowc = Cell.GetCount();
    strRowSta.Format("%d",irow);
    strRowEnd.Format("%d",irow + irowc -1);

    Cell = range.GetColumns();
    icol = Cell.GetColumn();
    icolc = Cell.GetCount();
    strColSta.Format("%d",icol);
    strColEnd.Format("%d",icol + icolc -1);