fork download
  1. Sub OpenFilesInFolder()
  2. Application.ScreenUpdating = False
  3. Application.DisplayAlerts = False
  4. Dim path, fso, file, files
  5. Dim target As Long
  6. path = ThisWorkbook.path & "\"
  7. 'xmlファイルを開く処理
  8. Set fso = CreateObject("Scripting.FileSystemObject")
  9. Set files = fso.GetFolder(path).files
  10. 'フォルダ内の全ファイルについて処理
  11. For Each file In files
  12. 'ファイルを開いてブック、シートとして取得
  13. Dim wb As Workbook
  14. Dim ws As Worksheet
  15. 'xmlファイルを開く処理
  16. If Right(LCase(file.name), 4) = ".xml" Then
  17. Workbooks.OpenXML _
  18. Filename:=file.path, LoadOption:=xlXmlLoadImportToList
  19. Set wb = ActiveWorkbook
  20. Set ws = ActiveSheet
  21. '開いたxmlファイルを順にコピペ処理
  22. With ThisWorkbook.Worksheets(1)
  23. target = .Cells(Rows.Count, 1).End(xlUp).Row + 1
  24. ws.Range(ws.Cells(2, 25), ws.Cells(49, 25)).copy
  25. .Range(.Cells(target, 1), .Cells(target + 47, 1)).PasteSpecial Paste:=xlPasteValues
  26. ws.Range(ws.Cells(2, 27), ws.Cells(49, 27)).copy
  27. .Range(.Cells(target, 2), .Cells(target + 47, 2)).PasteSpecial Paste:=xlPasteValues
  28. ws.Range(ws.Cells(2, 28), ws.Cells(49, 28)).copy
  29. .Range(.Cells(target, 3), .Cells(target + 47, 3)).PasteSpecial Paste:=xlPasteValues
  30. End With
  31. '保存せずに閉じる
  32. wb.Close SaveChanges:=False
  33. End If
  34. Next file
  35. DoEvents
  36. Application.DisplayAlerts = True
  37. Application.ScreenUpdating = True
  38. End Sub
  39.  
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty