【问题标题】:Applescript Find & Replace in Text Document from Excel SheetApplescript 在 Excel 工作表的文本文档中查找和替换
【发布时间】:2016-07-18 13:57:21
【问题描述】:

我是Applescript 的新手,我正在尝试创建一个脚本,该脚本可以在文本文档 (.html) 中运行,并在 Excel 文档中用相应的单元格查找和替换各种短语。

我会将占位符放在要替换的文本中,如B_1 (first value to replace), B_2 (second), B_3 等...

应使用 Excel 文档中的单元格 B1-B9 按顺序替换它们。 Excel 文档中的短语每次都会更改,因此必须动态捕获它们,而不是使用静态值的标准查找和替换脚本。

我一直在关注这个有道理的帖子:https://discussions.apple.com/thread/7008048?start=0&tstart=0

但是,我一直遇到编译错误。这是我当前的代码:

tell application "Microsoft Excel"
set colB_data to value of every cell of range "B1:B9" of worksheet 1 of document 1
end tell

tell application "Sublime Text"
tell text of "Users/maxquinn/Desktop/index.html"
repeat with index from 1 to count colB_data
replace ("B_" & index as text) using (item index of colB_data) options {starting at top:true, match words:true}
end repeat
end tell
end tell

前半部分工作正常,但后半部分给我错误"Expected end of line but found identifier." 并突出显示'replace' command (line 8) 中的'using'

有谁知道为什么会这样,脚本中是否还有其他明显的错误?

谢谢!

最大

【问题讨论】:

    标签: excel macos macros applescript


    【解决方案1】:

    对于未来的任何人,此问题已在 Apple 论坛上得到解决:https://discussions.apple.com/thread/7618440

    【讨论】:

      猜你喜欢
      • 2021-10-13
      • 2017-01-22
      • 2014-01-14
      • 1970-01-01
      • 2013-12-17
      • 2018-11-11
      • 2017-08-06
      • 1970-01-01
      • 2019-05-20
      相关资源
      最近更新 更多