【发布时间】:2015-02-24 08:12:59
【问题描述】:
我有一个要在共享网络驱动器 \\Share\Projects 上的文件夹中搜索的 pdf 文件名。 pdf 将位于项目下的子文件夹之一中。然后我想将 pdf 的整个文件路径返回到一个单元格中(例如 \\Share\Projects\Subfolder\Another subfolder\thisone.pdf)。
我已经启动了代码,但不知道如何搜索文件系统:
Sub InsertPath()
Dim PONumber As String
PONumber = InputBox("PO Number:", "PO Number")
'search for order
Dim myFolder As Folder
Dim myFile As File
'This bit doesn't work
Set myFolder = "\\Share\Projects"
For Each myFile In myFolder.Files
If myFile.Name = "PO" & PONumber & ".pdf" Then
'I have absolutely no idea how to do this bit
End If
Next
End Sub
我是在正确的轨道上还是我的代码完全错误?
【问题讨论】: