无法在映射驱动器上find新文件夹

我创build了一个自动将当前工作簿上传到共享点的macros,从而触发macros。 macros成功,将file upload到映射到驱动器的共享点文件夹。

但是,如果SharePoint文件夹是以前创build的方式,macros只能成功。 例如。 也许1天先进。

如果该文件夹是新创build的,它将无法上传到该文件夹​​作为Sorry there's no such folder

如果我去窗口资源pipe理器上的驱动器,我将能够看到新创build的文件夹。 我也尝试复制信息框中显示的文件path,并键入窗口资源pipe理器,它指示我没有问题的文件夹。

有没有一种方法可以加快这个过程,为什么会发生这种情况?

macrosIF语句

 If Dir(spPath) = "" Then MsgBox "Sorry there's no such folder. Folder Path: " & vbNewLine & vbNewLine & spPath & "" Call UnMapDrive(drive) Exit Sub ElseIf Not Dir(spPath & fileName) = "" Then MsgBox("File Already Exist!!!") ElseIf Dir(spPath & fileName) = "" Then FolderCreate (path) ThisWorkbook.SaveCopyAs copyPath & fileName Call FileCopy(path & fileName, spPath & fileName) MsgBox "File Successfully uploaded to SharePoint." Kill (path) & "*.*" RmDir path Call UnMapDrive(drive) End If 

更改

 If Dir(spPath) = "" Then 

 If Dir(spPath, vbDirectory) = "" Then 

直到有人将文件放到目录中(可能在创build目录后的一天),您的代码在那里没有看到任何文件(因为没有任何文件)。 通过添加vbDirectory它会查找目录本身。