纸取消动机获取表名称/excel.worksheet
我正在研究VSTO ADDIN,我想将功能区按钮标签更新为SheepDeactivate上的表名称(返回功能)。问题是,我正在使用的语法将SH变量发送为对象,而不是Excel.Worksheet,因此我找不到从中提取表信息的方法(名称)。 请告诉我我是否使用了正确的语法,如果我是正确的,如何将sh对象转换为excel.worksheet。
public partial class ThisAddIn
{
//KEEP THEM IN CHRONOLOGICAL ORDER
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
this.Application.SheetDeactivate += new Excel.AppEvents_SheetDeactivateEventHandler (ShDeactivate);
}
private void ShDeactivate(object Sh)
{
clsSheets.Ribbon_updateBackSheet(Sh);
}
I'm working on a VSTO addin, and I want to update a Ribbon button label to the sheet name on sheetDeactivate (a go back to functionality). The problem is, the syntax I'm using sends out the Sh variable as Object, not as Excel.Worksheet, so I could not find a way to extract sheet information from it (name).
Please tell me if I'm using the correct syntax, and if I am, how can I convert the Sh object to an Excel.worksheet.
public partial class ThisAddIn
{
//KEEP THEM IN CHRONOLOGICAL ORDER
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
this.Application.SheetDeactivate += new Excel.AppEvents_SheetDeactivateEventHandler (ShDeactivate);
}
private void ShDeactivate(object Sh)
{
clsSheets.Ribbon_updateBackSheet(Sh);
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
假设Sh-Object是图表或工作簿对象(请参见 https://learn.microsoft.com/en-us/office/vba/api/excel.application.sheetdeactivate )您应该只能使用
sh.name
获取对象的名称。Assuming that the Sh-object is either a chart or a workbook object (see https://learn.microsoft.com/en-us/office/vba/api/excel.application.sheetdeactivate) you should be able to just use
Sh.Name
to get the name of the object.