Excel VBA Check if directory exists error

后端 未结 7 987
别那么骄傲
别那么骄傲 2020-12-01 10:34

I have a spreadsheet that upon clicking a button will duplicate itself by copying/pasting everything to a new workbook and save the file with a name that is dependent upon s

7条回答
  •  无人及你
    2020-12-01 10:47

    To be certain that a folder exists (and not a file) I use this function:

    Public Function FolderExists(strFolderPath As String) As Boolean
        On Error Resume Next
        FolderExists = ((GetAttr(strFolderPath) And vbDirectory) = vbDirectory)
        On Error GoTo 0
    End Function
    

    It works both, with \ at the end and without.

提交回复
热议问题