|
だいたい、こんな感じかと思います。
Sub test7()
Dim vFileName As Variant
Dim i As Integer
Dim MyB As Workbook
ChDir ThisWorkbook.Path
With Application
vFileName = _
.GetOpenFilename("CSV ファイル (*.csv),*.csv", MultiSelect:=True)
If VarType(vFileName) = 11 Then
MsgBox "キャンセルされました。": Exit Sub
End If
.ScreenUpdating = False
End With
For i = LBound(vFileName) To Ubound(vFileName)
On Error GoTo NLine
With ThisWorkbook
Set MyB = Workbooks.Open(.Path & "\" & vFileName(i))
MyB.Worksheets(1).Copy Before:=.Worksheets(1)
End With
With ActiveSheet
If Len(.Name) > 23 Then
.Name = Right$(.Name, 23)
End If
End With
NLine:
MyB.Close False: Set MyB = Nothing
If Err.Number <> 0 Then Err.Clear
On Error GoTo 0
Next i
Application.ScreenUpdating = True
MsgBox "コピー処理を終了しました", 64
End Sub
|
|