Create a folder and sub folder in Excel VBA

后端 未结 13 1584
梦谈多话
梦谈多话 2020-11-28 05:43

I have a pull down menu of companies that is populated by a list on another sheet. Three columns, Company, Job #, and Part Number.

When a job is created I need a fo

13条回答
  •  旧巷少年郎
    2020-11-28 06:20

    There are some good answers on here, so I will just add some process improvements. A better way of determining if the folder exists (does not use FileSystemObjects, which not all computers are allowed to use):

    Function FolderExists(FolderPath As String) As Boolean
         FolderExists = True
         On Error Resume Next
         ChDir FolderPath
         If Err <> 0 Then FolderExists = False
         On Error GoTo 0
    End Function
    

    Likewise,

    Function FileExists(FileName As String) As Boolean
         If Dir(FileName) <> "" Then FileExists = True Else FileExists = False
    EndFunction
    

提交回复
热议问题