DateModule.vbs
FsoModule.vbs
WShllModule.vbs
※Include用のモジュールファイルは、スクリプトを保存するフォルダに「Module」というフォルダを作ってそこに格納しておく。
MemoEOF.vbs
Option Explicit
Include "DateModule"
Include "FsoModule"
Include "WShllModule"
Dim folderPath, fileName, filePath
folderPath = MakeFolder(GetBuildPath(Array(DesktopPath, "TXT", "memo")))
fileName = "memo" & DateFormat(Now, "[yyyy-mm-dd]hhnnss") & ".txt"
With Fso
filePath = .BuildPath(folderPath, fileName)
With .OpenTextFile(filePath, 8, True)
.Write StringN(20, vbCrLf)
.Write "[EOF]"
.Close
End With
End With
OpenFolder filePath
wShll.run "notepad " & filePath
'// 与えられた文字を指定回数つなげた文字列を返す
'// String関数で改行(vbCrLf)をつなげると vbCr だけになるため
Function StringN(ByVal n, ByVal str)
Dim i, strN
For i = 1 To n
strN = strN & str
Next
StringN = strN
End Function
'// 外部関数ライブラリ(VBSファイル)の読み込み
Function Include(ByVal mod_name)
Dim modFolderPath
With CreateObject("Scripting.FileSystemObject")
modFolderPath = .BuildPath(.GetFolder(".").Path, "Module")
With .OpenTextFile(.BuildPath(modFolderPath, mod_name & ".vbs"))
ExecuteGlobal .ReadAll
.Close
End With
End With
End Function