SplitTextFile.vbs
'ANSI形式で保存
arg = WScript.Arguments(0)
Set objFSO = WScript.CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile(arg)
lineCount = 0
fName = ""
flag = 1
path = objFSO.getParentFolderName(WScript.ScriptFullName) & "\"
Do While objFile.AtEndOfStream <> True
rbuf = objFile.ReadLine
If lineCount <> 0 and InStr(rbuf, "Attribute VB_Name = ") <> 0 And InStr(rbuf, """Attribute VB_Name = ") = 0 Then
newFile.Close
flag = 1
End If
If flag = 1 Then
fName = Mid(rbuf, InStr(rbuf, "=") + 3)
fName = Left(fName, Len(fName) - 1)
Set newFile = objFSO.CreateTextFile(path & fName & ".bas", true)
flag = 0
End If
lineCount = lineCount + 1
If InStr(rbuf, "Attribute VB_Name = ""m") <> 0 Then
rbuf = Replace(rbuf, "Attribute VB_Name = ""m", "Attribute VB_Name = ""M")
End If
newFile.WriteLine(rbuf)
Loop
newFile.Close
objFile.Close
Set objFile = Nothing
Set objFSO = Nothing
Set newFile = Nothing