回答受付終了まであと5日
pdfの仕分けをしたいのですが、他者から教えて貰って↓ので試しているのですが出来ません。何か問題があるのでしょうか? Sub PDF仕分け_Excelマッピング() Dim ws As Worksheet Dim basePath As String Dim lastRow As Long Dim i As Long Dim fileName As String Dim folderName As String Dim folderPath As String Dim fso As Object ' PDFがあるフォルダー(末尾に\を付ける) basePath = "C:\Users\YourName\Documents\PDF整理\" Set fso = CreateObject("Scripting.FileSystemObject") Set ws = ThisWorkbook.Sheets("Sheet1") lastRow = ws.Cells(ws.Rows.Count, "A").End(xlUp).Row For i = 2 To lastRow ' ヘッダーがある場合は2から fileName = ws.Cells(i, 1).Value folderName = ws.Cells(i, 3).Value folderPath = basePath & folderName ' PDFが存在かつ移動先フォルダーも存在する場合 If fso.FileExists(basePath & fileName) And fso.FolderExists(folderPath) Then fso.GetFile(basePath & fileName).Move folderPath & "\" & fileName Debug.Print fileName & " → " & folderPath Else Debug.Print "移動できない: " & fileName End If Next i MsgBox "【】 PDFの仕分け完了(Excelマッピング版)" End Sub
Visual Basic・33閲覧・50