>> 99
1つにまとめてみた
読み取り専用ファイルの場合は標準ファイルに変更して開き直す
標準ファイルの場合は上書き保存後閉じて読み取り専用ファイルに変更する
var fs = new ActiveXObject("Scripting.FileSystemObject");
var path = Editor.ActiveDocument.FullName;
var file = fs.GetFile(path);
if(file.Attributes % 2 == 0)
{
Editor.ActiveDocument.Save();
Editor.ActiveDocument.Close();
file.Attributes = file.Attributes + 1;
}
else
{
Editor.ActiveDocument.Close();
file.Attributes = file.Attributes - 1;
if(Editor.ActiveDocument.FullName || Editor.ActiveDocument.Text)
Editor.NewFile();
Editor.OpenFile(file);
}