0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

あるディレクトリから、pdfファイルのみの Filenameをエクセルのvalueにいれる

Posted at

  '以下VBA

Sub ListPDFFilenames()
Dim folderPath As String
Dim fileName As String
Dim cell As Range
Dim ws As Worksheet
Dim lastRow As Long

' シートを設定
Set ws = ThisWorkbook.Sheets(1)

' フォルダパスを指定
folderPath = "C:\Your\Directory\Path\Here\" ' 適切なフォルダパスに置き換えてください

' フォルダパスの最後にバックスラッシュを追加
If Right(folderPath, 1) <> "\" Then folderPath = folderPath & "\"

' 初期設定
fileName = Dir(folderPath & "*.pdf")
lastRow = 1

' PDFファイルを探して一覧表示
Do While fileName <> ""
    ' PDFファイルの名前をA列に記入
    ws.Cells(lastRow, 1).Value = fileName
    lastRow = lastRow + 1
    fileName = Dir
Loop

End Sub

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?