셀 B6에 저장된 주소에 폴더를 만들려고합니다. 주소는 다음과 같습니다 H : \ jpDesk \ 바탕 화면 \ 테스트 프로젝트Excel VBA MkDir 런타임 오류
Sub SetUpLocalFolder()
Workbooks("Robot Model.xlsm").Activate
LocalPath = ActiveWorkbook.Worksheets("Preparation").Range("B6").Value
Debug.Print LocalPath
If Right(LocalPath, 1) <> "\" Then LocalPath = LocalPath & "\"
'check if the folder is already created
If Len(Dir(""" & LocalPath & """, vbDirectory)) = 0 Then
MkDir """ & LocalPath & """ 'Error shows here
MsgBox ("The local folder is successfully created.")
End If
End Sub
오류가 "런타임 오류 '76'경로를 찾을 수 없습니다."표시되지만을 Debug.Print은 올바른 주소를 보여줍니다. 코드를 MkDir "H : \ jpDesk \ Desktop \ Test Project"로 변경하면 모든 것이 작동합니다. 누군가 나에게 이유를 알려 주실 수 있습니까?
"" " – Slai
"대신 "Scripting.FileSystemObject"를 사용하는 것이 좋습니다. 기존의 파일 처리 방법보다 훨씬 강력합니다. – Comintern
고마워요! – vivi11130704