' ' 単純テキストファイル→HTML文書ファイル ' Set fso = WScript.CreateObject("Scripting.FileSystemObject") Set arg = WScript.Arguments '------------------------------------------------------------------------------- 'アイコンクリックで起動した場合 ' If arg.Count = 0 Then a = InputBox("ファイル名(フルパス名)を入力して下さい。", "TXT → HTML") If a = "" Then MsgBox "使用法:変換したいファイルをアイコンにドラッグ&ドロップしても変換できます。" WScript.Quit 0 Else textfile = a End If Else textfile = arg(0) End If '------------------------------------------------------------------------------- 'テキストファイルの読み込み ' If Not fso.FileExists(textfile) Then MsgBox "指定した名前のファイルが見つかりません。(" & textfile & ")" WScript.Quit 0 End If mode = 0 'ANSI/Shift_JIS mode = -1 'UTF-16 Set txtf = fso.OpenTextFile(textfile,0,mode) tmp = txtf.ReadLine firstline = Ucase(Left(tmp, 4)) txtf.Close Select Case firstline Case "" Do Until txtf.AtEndOfStream tmp = txtf.ReadLine htmf.WriteLine tmp & "
" Loop htmf.WriteLine "" htmf.Close txtf.Close '------------------------------------------------------------------------------- '--- 表示 If MsgBox("変換したHTML文書ファイルを開きますか?", vbYesNo) = vbYes Then Set wso = Wscript.CreateObject("WScript.Shell") wso.Run htmlfile End If