所以我使用Visual Basic非常新,我遇到了麻烦。我想打开一个文件夹并阅读文件夹中的所有PDF内容。我在Microsoft Guidelines上找到了此代码,但收到了有关某些代码期望的错误:
For Each foundFile As String In My.Computer.FileSystem.GetFiles(
My.Computer.FileSystem.SpecialDirectories.MyDocuments,
Microsoft.VisualBasic.FileIO.SearchOption.SearchAllSubDirectories, "*.pdf")
Listbox1.Items.Add(foundFile)
Next
有谁知道我为什么会收到这样的错误?
答案 0 :(得分:0)
看看这是否有用
Sub Dougsloop()
Dim Filename As String
Dim path As String
path = "path to folder" & "\"
Filename = Dir(path & "*.pdf")
Do While Len(Filename) > 0
debug.print; FileName
'Listbox1.Items.AddItem (Filename) replace debug w/this
Filename = Dir
Loop
End Sub