放置庫

とりあえず手を出してみる。

個人用マクロブック編集

普段は読取専用にしておいて、だけど編集したいときにはワンタッチで読取専用解除。
…しようと思ったんだけど、なぜか解除されたと見なされず上書き保存できない。なぜ?


Set objFSO = WScript.CreateObject(“Scripting.FileSystemObject”)
Set WSHShell = WScript.CreateObject(“WScript.Shell”)
fp=WshShell.SpecialFolders(“Templates”) & “..\Application Data\Microsoft\Excel\XLSTART\PERSONAL.xls”
msgbox fp

Set objFile = objFSO.GetFile(fp)
objFile.Attributes = (objFile.Attributes And (255 - 1))
set objFile = nothing

‘Excelで開く
Set app = CreateObject(“Excel.Application”)
app.Visible = True
app.WorkBooks.Open fp, , True
wshShell.AppActivate app.Caption
WSHShell.SendKeys “%{F11}”

do while app.Visible
 Wscript.sleep 1000
loop

set app = nothing

Set objFile = objFSO.GetFile(fp)
objFile.Attributes = (objFile.Attributes Or 1)
Set objFile = nothing