且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Excel VBA - MkDir返回“找不到路径”使用变量时

更新时间:2023-11-22 20:17:28

问题是您正在使用 Chr(10)这不是删除空格,因此当你调用 ProjFolder = COPSFolder&InProgress\& InfoArray(3),您在 InfoArray(3)中有空格

The problem is that you are splitting using Chr(10) This is not removing the spaces. And hence when you are calling ProjFolder = COPSFolder & "InProgress\" & InfoArray(3), you have spaces in InfoArray(3)

您有3个选项


  1. 当您创建阵列时,请删除那里的空格或

  1. When you are creating the array, remove the spaces there OR

当您分配 InfoArray = GetPartInfo(File.Path)时,删除那里的空格或

When you are assigning InfoArray = GetPartInfo(File.Path), remove the spaces there OR

更改ProjFolder = COPSFolder&InProgress\& InfoArray(3)到 ProjFolder = Trim(InfoArray(3))

Change the line ProjFolder = COPSFolder & "InProgress\" & InfoArray(3) to ProjFolder = COPSFolder & "InProgress\" & Trim(InfoArray(3))