在共享驱动器上上传Excel工作簿

我已经创build了一个从其他Excel工作簿收集数据的主工作簿。 以下是放置其​​他工作簿的path(需要从中收集数据),而我的主工作簿位于桌面上。 以下是我正在使用的代码。

' 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 

当我在共享驱动器上传这个文件时,我正在给我的path如下:

"\\151.208.196.138\ATS shared drive\F&HC\PSG OPS\New DDS Sheet"

但是这是给错误的。 有谁能够帮助我?

UNC( 通用命名约定 )基本上是完整的文件path位置。 它采取的格式是:

 \\Server\Share\filepath 

注意"\\"

在你的情况下,它会

 "\\151.208.196.138\ATS shared drive\F&HC\PSG OPS\New DDS Sheet"