纸取消动机获取表名称/excel.worksheet

发布于 2025-01-30 04:48:21 字数 634 浏览 2 评论 0原文

我正在研究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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

星星的轨迹 2025-02-06 04:48:21

假设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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文