尝试使excel粘贴未格式化的文本时出现Applescript错误

时间:2012-10-12 12:10:30

标签: applescript applescript-excel

我正在遵循这些说明:http://blog.mackerron.com/2009/05/19/paste-unformatted-keyboard-shortcut-office-2008-mac/ 在Word中工作得很好。但是当我将下面的代码粘贴到Applescript中并将其保存到/Documents/Microsoft User Data/Excel Script Menu Items时,我收到此错误Syntax Error: Expected end of line, etc. but found “text”.

try
  set theClip to Unicode text of (the clipboard as record)
  tell application "Microsoft Excel" to tell selection to type text text theClip
end try

这里出了什么问题?

2 个答案:

答案 0 :(得分:1)

尝试:

set theClip to the clipboard as text

tell application "Microsoft Excel"
    activate
    set value of active cell to theClip
end tell

或者这个:

set theClip to the clipboard as text

tell application "Microsoft Excel" to activate
tell application "System Events" to tell process "Microsoft Excel"
    keystroke theClip
end tell

在此处拖动脚本:

tell application "Finder" to open (path to library folder from user domain as text) & "Application Support:Microsoft:Office:Excel Script Menu Items:"

enter image description here

答案 1 :(得分:0)

to type text text

也许你应该重命名变量文本?