使用 applescript 在特定工作表上的 iWork 数字中创建新表格
我在使用 Applescript 在特定工作表上创建新表时遇到问题,除非我想要插入新表的工作表是新的或当前选择的。 我正在使用的代码的一般形式是:
tell application "Numbers"
tell document 1
tell sheet "This is the sheet I want to use"
make new table with properties {name:"A new table"}
end tell
end tell
end tell
有没有人在实现这一目标方面取得了更多成功? 在我看来,这对于 Numbers 中的某些高级电子表格脚本来说有点问题。
I am having trouble creating a new table on a specific sheet using Applescript unless the sheet I want insert the new table in is either new or current selected.
The general form of the code I am using is:
tell application "Numbers"
tell document 1
tell sheet "This is the sheet I want to use"
make new table with properties {name:"A new table"}
end tell
end tell
end tell
Has anyone had any more success at achieving this? This looks to me like a bit of a problem for some advanced spreadsheet scripts in Numbers.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好的。 我的第一个答案被接受并且无法删除,但还不够,所以我决定编辑它并添加一些确实解决问题的代码!
该代码由 Yvan Koenig 提供,归功于 Nigel Garvey。 两者都在 applescript-users 列表 上活跃,顺便说一句,这非常好,尤其是因为这两位先生以及许多其他伟大的 AppleScripters 的活动。
它依赖于 GUI 脚本(不得不依赖这总是一件可怕的事情,但这就是我们所拥有的)。
对
my activateGUIscripting()
的调用可能会导致出现输入管理员密码的提示。 如果您绝对知道已启用 GUI 脚本(系统首选项 -> 通用访问 -> 启用辅助设备访问) - 那么您可以省略此行。接下来的两行只是示例调用,因此您需要一个名为“Sheet 1”的工作表才能使这些示例调用正常工作。
这将允许您在任何文档的任何工作表中创建表格,无论选择什么或最前面的内容。
OK. My first answer was accepted and could not be deleted, but was inadequate, so I have decided to edit it and add some code which really does solve the problem!
This code comes via Yvan Koenig, who credits Nigel Garvey. Both are active on the applescript-users list, which is excellent, by the way, not least because of the activity of these two gentlemen, and so many other great AppleScripters.
It relies on GUI scripting (which is always a horrible thing to have to fall back on, but it's what we've got).
The call to
my activateGUIscripting()
may cause a prompt for an admin password to appear. If you absolutely know that you have GUI scripting enabled (System Prefs->Universal Access->Enable Access for Assistive Devices) - then you can omit this line.The next two lines are just example calls, so you need a sheet called "Sheet 1" for these example calls to work.
This will allow you to create a table in any sheet in any document, regardless of what is selected or frontmost.