如何在不使用application.selection属性的情况下在excel中获取所选对象 [英] How to get the selected object in excel without using application.selection property

查看:257
本文介绍了如何在不使用application.selection属性的情况下在excel中获取所选对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

TechGurus,



我已经覆盖了Excel并根据所选对象进行了多次操作。

我得到了正确的选择使用application.selection属性的对象

object selectedObj = _xlApp.ActiveWindow.Selection;

并根据所选对象检查所选对象是否不是Range对象然后调用默认的windowProc,以便Excel可以处理这些消息。

Hi TechGurus,

I have overwritten the Excel and doing multiple manipulations based the selected object.
I am getting the correct selected object by using the application.selection property
object selectedObj = _xlApp.ActiveWindow.Selection;
and based on the selected object I am checking if the selected object is not a Range object then call the default windowProc so that Excel can handle those messages.

if (!(selectedObj is MsExcel.Range))
{
      base.WndProc(ref msg);
      handled = true;
}



但是,由于指令:object selectedObj = _xlApp.ActiveWindow.Selection;

我无法调整大小Excel中注释窗口的大小。



请建议一些其他方法来获取所选对象。



先谢谢。



- virenk


But, due to instruction: object selectedObj = _xlApp.ActiveWindow.Selection;
I am not able to resize the size of comment window in Excel.

Please suggest some other method through which i can get the selected object.

Thanks in Advance.

- virenk

推荐答案

你需要引用单元格/你想稍后使用的范围:

伪代码:

You need to reference to the cell/range, which you want to use later:
In pseudocode:
Excel.Workbook Wbk = _xlApp.Workbooks.Open("fullfilename")
Excel.Worksheet Wsh = Wbk.Worksheets(index)
Excel.Range Rng = Wsh.Range("A1")

if (Rng.Value2 == 5)
{
     //do something
}


这篇关于如何在不使用application.selection属性的情况下在excel中获取所选对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆