返されたテキストと返されたボタンの組み合わせによって、開いているExcelシートの特定のセルが変更されたスクリプトを作成しようとしています。基本的に1を加えたり、指定したセルの現在の値から1を引いたりします。以下のコードを使用して今動作するのは、ユーザーが -cancel-ボタンをクリックしたときだけです。「変更は行われませんでした」というダイアログが表示されます。これは予想通りです。AppleScriptを使用してExcelセル+1または-1の値を変更する方法
「12502525981」というテキストを入力して追加ボタンをクリックしてもエラーは発生しません。単に何も起こらない。
また、私はそれが私に期待する方法を凌駕するとは思わないと思います。
多くの感謝のExcelに組み込まれてVBAを使用しないのはなぜ
try
set upcItem1 to "12502525981"
set upcItem2 to "12502600695"
set upcItem3 to "12502612346"
set the_Response to {text returned, button returned} of (display dialog "Enter the UPC of the item below..." buttons {"Add +1 ", "-Cancel-", "Remove -1"} default answer "")
item 1 of the_Response -- the text
item 2 of the_Response -- the button pressed
if item 2 of the_Response is equal to "Add +1" & item 1 of the_Response contains upcItem1 then
tell application "Microsoft Excel"
set value of cell "C2" to current value +1
end tell
else if item 2 of the_Response is equal to "Remove -1" & item 1 of the_Response contains upcItem1 then
tell application "Microsoft Excel"
set value of cell "C2" to current value -1
end tell
else if item 2 of the_Response is equal to "-Cancel-" then
display notification "No change was made."
end if
on error
display notification "There was a problem with the UPC entered, try again or check the cell that it relates to."
end try
? – Chrismas007
組織内でマクロを使用することはできません。だから私は他のメソッド –