//選択範囲の行を逆順に並べ直すマクロ //選択範囲を指定していなければ全文を選択する if (document.selection.Text == "") document.selection.SelectAll(); //改行記号を拠所にして選択範囲の文字列を配列化して、逆順に並べ直して、再結合し、末尾に改行を追加 document.selection.Text = document.selection.Text.split(/\n/).reverse().join("\n") + "\n"; //キャレットを選択範囲の先頭に移動(無効化するとキャレットは選択範囲の末尾に居座る) document.selection.StartOfDocument();