excel AppleScript有语法错误,因为引号,如何解决它?

ee7vknir  于 2023-01-31  发布在  其他
关注(0)|答案(1)|浏览(136)

谢谢你的帮助。我正在尝试更改N列中包含音乐曲目子类别的单元格,如果代码在R列中找到了我要查找的曲目标题

-- Declare variables
property searchTrackTitle : ""
property newSubCategory : ""

-- Display input box to get search term
display dialog "Enter the track title that you want to search for:" default answer ""
set searchTrackTitle to text returned of result

-- Display input box to get new SubCategory
display dialog "Enter the new SubCategory that you want to use:" default answer ""
set newSubCategory to text returned of result

-- Open Excel and set variables
tell application "Microsoft Excel"
    activate
    set sh to active sheet
    set rng to range "R:R" of sh
end tell

-- Loop through each cell in the range
repeat with cell in rng
    -- Check if the cell value matches the search term
    if value of cell is searchTrackTitle then
        -- Update the keywords for the track title
        set value of cell "N" of sh to newSubCategory
    end if
end repeat
qcbq4gxm

qcbq4gxm1#

在Excel中,您在作业结束前输入“end tell”,并尝试使用正确的代码将变量赋给类名:

-- Declare variables
property searchTrackTitle : ""
property newSubCategory : ""

-- Display input box to get search term
display dialog "Enter the track title that you want to search for:" default answer ""
set searchTrackTitle to text returned of result

-- Display input box to get new SubCategory
display dialog "Enter the new SubCategory that you want to use:" default answer ""
set newSubCategory to text returned of result

-- Open Excel and set variables
tell application "Microsoft Excel"
    activate
    set sh to active sheet
    set rng to range "R:R" of sh
    
    -- Loop through each cell in the range
    repeat with currentCell in rng
        -- Check if the cell value matches the search term
        if value of currentCell is searchTrackTitle then
            -- Update the keywords for the track title
            set value of cell "N" of sh to newSubCategory
        end if
    end repeat
end tell

相关问题