【问题标题】:AppleScript to get value of active cell from Excel sheetAppleScript 从 Excel 工作表中获取活动单元格的值
【发布时间】:2012-04-17 13:12:37
【问题描述】:

试图从 Excel 工作表中获取当前突出显示的单元格的值

set x to null
tell application "Microsoft Excel"
    tell worksheet "Sheet1" of active workbook
       set x to value of active cell as string
       display dialog x
    end tell
end tell

AppleScript 将 x 设置为“缺失值”。我在这里做错了什么,还有其他方法可以获取活动单元格的值吗?

我在 MAC 版本 14.0.0 上使用 Microsoft Excel 2011

【问题讨论】:

    标签: excel applescript


    【解决方案1】:

    如果您查看 excel 的 applescript 字典,您会发现“活动单元格”是应用程序的一个属性。它不是工作表或工作簿的属性。所以这行得通...

    tell application "Microsoft Excel"
        set x to value of active cell as string
        display dialog x
    end tell
    

    它也是一个窗口的属性,所以它也可以工作......

    tell application "Microsoft Excel"
        tell window 1
            set x to value of active cell as string
            display dialog x
        end tell
    end tell
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-08-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多