我创建了一个主工作簿,可以从其他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"
但这是错误的。有人可以帮助我吗?
答案 0 :(得分:2)
UNC(通用命名约定)基本上是完整的文件路径位置。它采用以下格式:
\\Server\Share\filepath
请注意"\\"
?
在你的情况下,它将是
"\\151.208.196.138\ATS shared drive\F&HC\PSG OPS\New DDS Sheet"