Sub 读写txt()
Dim j As Integer
Dim i&, s() As String
For j = 1 To 10
Open ThisWorkbook.Path & "\" & Range("A" & j) & ".txt" For Input As #1
s = Split(StrConv(InputB(LOF(1), 1), vbUnicode), vbCrLf)
Close #1
Open ThisWorkbook.Path & "\" & Range("A" & j) & ".txt" For Output As #1
For i = 0 To UBound(s)
If InStr(s(i), " Print #1, s(i)
Next
Close #1
Next j
End Sub
=""&""""
Chr(34)
Chr(10)是不行的,因为回车符是双字节字符,用这个Chr(13) & Chr(10)
chr(13)和chr(10)在win系统下都是一样效果,
而在linux系统中,有效的换行只能为为chr(10),即/n
为了统一格式和兼容,所有文本换行一率采用\r\n,即chr(13)+chr(10)的组合来确定
Sub 读写htm()
Dim j As Integer
Dim i&, s() As String
For j = 1 To 10
Open ThisWorkbook.Path & "\" & Range("A" & j) & ".htm" For Input As #1
s = Split(StrConv(InputB(LOF(1), 1), vbUnicode), vbCrLf)
Close #1
Open ThisWorkbook.Path & "\" & Range("A" & j) & ".htm" For Output As #1
For i = 0 To UBound(s)
'Debug.Print " If InStr(s(i), " Print #1, s(i)
Next
Close #1
Next j
End Sub
Sub 插入时间()
Dim j As Integer
Dim i&, s() As String
For j = 2 To 40
Debug.Print ThisWorkbook.Path & "\ppt\ppt.files\" & Range("P" & j) & ".htm"
Open ThisWorkbook.Path & "\ppt\ppt.files\" & Range("P" & j) & ".htm" For Input As #1
s = Split(StrConv(InputB(LOF(1), 1), vbUnicode), vbCrLf)
Close #1
Open ThisWorkbook.Path & "\ppt\ppt.files\" & Range("P" & j) & ".htm" For Output As #1
For i = 0 To UBound(s)
'Debug.Print " If InStr(s(i), " s(i) = Replace(s(i), " ElseIf InStr(s(i), "--><![endif]>") Then
s(i) = Replace(s(i), "--><![endif]>", "--><![endif]>" & Range("R" & j))
Else
Debug.Print Range("I" & j)
End If
Print #1, s(i)
Next
Close #1
Next j
End Sub