Sub setDate()
Dim baseFile As String
Dim newFile As String
Dim Stream As Object
Dim Stream2 As Object
Dim buf As String
Set Stream = CreateObject("ADODB.Stream")
Set Stream2 = CreateObject("ADODB.Stream")
Dim myfdr As String
Application.ScreenUpdating = False '画面更新を一時停止
myfdr = ThisWorkbook.Path 'フォルダー名取得
baseFile = Dir(myfdr & "\*.txt") 'フォルダ内のtxtファイルを検索
Dim n As Long
n = 0
Do Until baseFile = Empty '全て検索 Do While baseFile <> ""
newFile = baseFile & ".rep" ' Workbooks.Open(myfdr & "\" & baseFile) 'そのファイルを開きwbとする。
n = n + 1 'カウントしnとする
'wb = Replace(wb, ">", "<a href=""#1"" title=本文へ></a>>")
Stream.Open
Stream.Type = 2 '文字列で保存
Stream.Charset = "utf-8" '文字列をutf-8で取得
Stream.LoadFromFile baseFile 'basefaile読み込み
buf = Stream.readText()
Stream.SaveToFile newFile, 2
buf = Replace(buf, "blue", "red")
Stream2.Open
Stream2.Type = 2
Stream2.Charset = "utf-8"
Stream2.WriteText (buf)
Stream2.SaveToFile newFile, 2
Stream.Close
Stream2.Close
'wb.Close (True) '開いたファイルを保存して閉じる
baseFile = Dir 'フォルダ内の次のtxtファイルを検索
Loop '繰り返す
Application.ScreenUpdating = True '画面更新一時停止を解除
If Dir(myfdr & "\*.txt") <> "" Then
MsgBox n & "件を処理しましました。"
MsgBox "変換終了"
Else
MsgBox "ファイルは存在しません。", vbInformation
End If
End Sub
Sub setDate()
Dim baseFile As String
Dim newFile As String
Dim Stream As Object
Dim Stream2 As Object
Dim buf As String
Set Stream = CreateObject("ADODB.Stream")
Set Stream2 = CreateObject("ADODB.Stream")
Dim myfdr As String
Application.ScreenUpdating = False '画面更新を一時停止
myfdr = ThisWorkbook.Path 'フォルダー名取得
baseFile = Dir(myfdr & "\*.txt") 'フォルダ内のtxtファイルを検索
Dim n As Long
n = 0
Do Until baseFile = Empty '全て検索 Do While baseFile <> ""
newFile = baseFile & ".rep" ' Workbooks.Open(myfdr & "\" & baseFile) 'そのファイルを開きwbとする。
n = n + 1 'カウントしnとする
'wb = Replace(wb, ">", "<a href=""#1"" title=本文へ></a>>")
Stream.Open
Stream.Type = 2 '文字列で保存
Stream.Charset = "utf-8" '文字列をutf-8で取得
Stream.LoadFromFile (myfdr & "\" & baseFile) 'basefaile読み込み
buf = Stream.readText()
Stream.SaveToFile newFile, 2
buf = Replace(buf, "blue", "red")
Stream2.Open
Stream2.Type = 2
Stream2.Charset = "utf-8"
Stream2.WriteText (buf)
Stream2.SaveToFile myfdr & "\" & newFile, 2
Stream.Close
Stream2.Close
'wb.Close (True) '開いたファイルを保存して閉じる
baseFile = Dir 'フォルダ内の次のtxtファイルを検索
Loop '繰り返す
Application.ScreenUpdating = True '画面更新一時停止を解除
If Dir(myfdr & "\*.txt") <> "" Then
MsgBox n & "件を処理しましました。"
MsgBox "変換終了"
Else
MsgBox "ファイルは存在しません。", vbInformation
End If
End Sub