2
我创建了一个主工作簿,用于收集其他Excel工作簿中的数据。以下是放置其他工作簿的路径(需要从中收集数据),而我的主工作簿位于桌面上。以下是我正在使用的代码。在共享驱动器上上传Excel工作簿
' Change this to the path\folder location of the files.
MyPath = "C:\P&G\"
' Add a slash at the end of path if needed.
If Right(MyPath, 1) <> "\" Then
MyPath = MyPath & "\"
End If
' If there are no Excel files in the folder, exit.
FilesInPath = Dir(MyPath & "*.xl*")
If FilesInPath = "" Then
MsgBox "No files found"
Exit Sub
End If
' Fill in the myFiles array with the list of Excel files in
' the search folder.
FNum = 0
Do While FilesInPath <> ""
FNum = FNum + 1
ReDim Preserve MyFiles(1 To FNum)
MyFiles(FNum) = FilesInPath
FilesInPath = Dir()
Loop
当我上传共享驱动器上的文件,我给我的路径如下:
"\\151.208.196.138\ATS shared drive\F&HC\PSG OPS\New DDS Sheet"
但这给错误。有谁能够帮助我?
仍然给错误。如果文件夹中没有Excel文件,请退出。 FilesInPath = DIR(mypath中与 “* .xl *”) 如果FilesInPath = “” 那 MSGBOX “找不到文件” 退出小组 结束如果 存在FilesInPath的错误。 :( –
将'Dir(MyPath&“.xl”)'改为'Dir(MyPath&“.xl *”)' –
现在给出错误,表示没有找到文件。 –