Excel中多个选择的工作表是什么对象类型? [英] What object type are multiple selected sheets in Excel?

查看:150
本文介绍了Excel中多个选择的工作表是什么对象类型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

与我的想法相反,多个选定的工作表不是Worksheets对象类型.

Contrary to what I would think, multiple selected sheets are not a Worksheets object type.

多次选择2张或更多张纸后.我得到选择的方式是这样的:

After multi-selecting 2 or more sheets. The way I get the selection is as so:

var selection = ExcelApp.Selection; //Returns object type

我试图通过使用后期绑定来获取"Name"属性,并通过提示给我提示:

I've tried getting the "Name" property to try and give me a hint by using late binding with:

string name = selection.GetType().InvokeMember("Name", System.Reflection.BindingFlags.GetProperty, null, selection, null).ToString();

但是对于给定的选择类型,这会引发错误.

But this throws errors for the given selection type.

有什么想法吗?

推荐答案

在VBA中,ActiveWindow.SelectedSheets返回一个Sheets集合,所以我想它在C#中将是类似的

In VBA, ActiveWindow.SelectedSheets returns a Sheets collection, so I imagine it will be similar in C#

是的: http://msdn.microsoft.com/zh-CN/library/microsoft.office.interop.excel.window.selectedsheets(v=office.11​​).aspx

这篇关于Excel中多个选择的工作表是什么对象类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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