2012-03-06 2 views
2

Microsoft Wordでハイパーリンクを切り替えるためにAppleScriptを書き込もうとしています。 (これは通常、Alt + F9を押すことによって行われます)。ここでハイパーリンクを切り替えるAppleScript

は私のスクリプトだが、それは動作しません:

tell application "Microsoft Word" 
     keystroke F9 using {option down} 
end tell 

ちょうど私にエラーを与えること:

"Expected end of line but found identifier"

私が使用している場合:

tell application "System Events" 
    tell application "Microsoft Word" 
     keystroke F9 using {option down} 
    end tell 
end tell 

ことがなく、動作します何もしません。

そして、私が使用している場合:

tell application "System Events" 
    tell application "Microsoft Word" 
     keystroke "Hello" 
    end tell 
end tell 

それだけ版画 "こんにちは" のAppleScriptウィンドウで。私はMSの言葉に影響を与える必要があります。

答えて

1

ここでは、シミュレートされたキーボードショートカットをスクリプトする必要はありません。 (例えばフォーム{HYPERLINK "http://www.stackoverflow.com"}と実際のハイパーリンクとの間の)フィールドコードを切り替えるために、このスクリプトを使用する:これはまた、ページ番号などの他のフィールドコードを切り替えます

# toggle field codes 
# same as option + F9 
# tested in Microsoft® Word 2008 for Mac v 12.2.3 
tell application "Microsoft Word" 
    set theView to active window's active pane's view 
    if (show field codes of theView) then 
     set show field codes of theView to false 
    else 
     set show field codes of theView to true 
    end if 
end tell 

に留意、オフとオン。

+0

awesome!完璧に動作します。ありがとう。 – solerous