|
Sub Mg_Text()
Dim MyF As Variant, MyV As Variant
Dim Ret As Long
Dim FSO As Object
Dim CmdSt As String, AllSt As String
Const Ph As String = _
"C:\Documents and Settings\User\My Documents"
ChDir Ph
With Application
MyF = .GetOpenFilename("テキストファイル(*.txt),*.txt", _
MultiSelect:=True)
If VarType(MyF) = 11 Then Exit Sub
.ScreenUpdating = False
End With
If Dir(Ph & "\Marge.txt") <> "" Then Kill Ph & "\Marge.txt"
CmdSt = "CMD.EXE /C COPY "
For Each MyV In MyF
CmdSt = CmdSt & Dir(MyV) & "+"
Next
CmdSt = Left$(CmdSt, Len(CmdSt) - 1) & " Marge.txt"
Ret = Shell(CmdSt, 2)
With Application
.Wait Time + TimeValue("00:00:01")
.ScreenUpdating = True
ChDir .DefaultFilePath
End With
If Ret = 0 Then
MsgBox "COPYコマンドは失敗しました", 48: Exit Sub
End If
Set FSO = CreateObject("Scripting.FileSystemObject")
With FSO.OpenTextFile(Ph & "\Marge.txt", 1)
AllSt = .ReadAll
.Close
End With
Set FSO = Nothing
*ここに AllSt に対して InStr関数 などで特定の文字を検索し、
それを基に何かの処理をするコードを書きます。
End Sub
|
|