2017-12-20 50 views
1

私のようなもので、セルから枠線を削除することができます。ワークシートのすべての罫線を削除するにはどうすればよいですか? AppleScriptとExcelでは

tell application "Microsoft Excel" 
    set myRange to range "B2:B2" of active sheet 
    set myBorders to {border top, border bottom, border left, border right} 
    repeat with i from 1 to 4 
     set theBorder to get border myRange which border (item i of myBorders) 
     set line style of theBorder to line style none 
    end repeat 
end tell 

Remove cell bordersから学んだが、私は、各列をステップ実行することなく、ワークシートからすべての国境を削除しようとしている問題を持つとしています行。

set activeSheet to worksheet (get name of active sheet) of workbook (get name of active workbook) 

と私は見ドキュメンテーション研究:私はアクティブなシートを取得する方法を考え出した

autoshape line callout one no border 
autoshape line callout two no border 
autoshape line callout three no border 
autoshape line callout four no border 

を私はせずに、すべての境界線を削除する方法を見つけ出すように見えることはできません各列と行にステップインします。私の検索結果から "How do I use AppleScript to clear a range of cells in excel 2008"が見つかりましたが、それはうまくいかなかったのです。ワークシートのすべての罫線を削除する簡単な方法はありますか?

+0

いいえセルの周りのすべての枠線と線を削除したいとします。 –

+1

同等の機能は、シート全体を選択し、枠線に移動し、枠線を選択しないことです –

答えて

1

アクティブシートの使用範囲にアクセスして、その範囲からすべての罫線を削除できます。

tell application "Microsoft Excel" 
    set usedRange to used range of active sheet 
    set myBorders to {border top, border bottom, border left, border right} 
    repeat with i from 1 to 4 
     set theBorder to get border usedRange which border (item i of myBorders) 
     set line style of theBorder to line style none 
    end repeat 
end tell