Excel VBA - MkDir returns “Path not Found” when using variable

前端 未结 1 1420
南笙
南笙 2020-12-12 02:04

So here\'s the relevant snippet of my code (COPSFolder is a constant defined elsewhere):

Sub CreateReport(ByRef InfoArray() As String)

Dim BlankReport As Wo         


        
相关标签:
1条回答
  • 2020-12-12 02:40

    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)

    You have 3 options

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

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

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

    0 讨论(0)
提交回复
热议问题