VBA를 사용하여 로컬 xlsm 파일을 SharePoint 온라인에 업로드하려고합니다. 파일은 사용자가 파일을 저장 한 후 SharePoint에 자동 업로드됩니다. 개념은 사용자가 xlsm 파일을 저장 한 후에 복사 된 파일이있는 새 폴더를 만들고 폴더에 복사 된 파일을 SharePoint에 업로드합니다. 업로드 후 폴더가 삭제됩니다.VBA - 런타임 오류 1004
그러나, 나는 인해
에 폴더에 파일을 저장할 수 없습니다 해요내가 가능한 이유를 확인, 파일 이름/경로가 폴더를 존재 만들었습니다.런타임 오류
1004
파일이 다른 프로그램에서 사용하고 있지 않으며 Excel에서만 파일을 실행합니다.
폴더가 새로 만들어지며 빈 폴더인데 이름이 같은 파일이 포함되어 있지 않습니다.
나는 모든 경로를 확인했고, 그들은 모두 정확합니다.이
내 코드Private Sub Workbook_AfterSave(ByVal Success As Boolean)
Dim UploadToSharepoint As Boolean
Dim SharePointLib As String
Dim myPath As String
Dim folderPath As String
Dim objNet As Object
Dim FS As Object
Dim copyPath As String
Dim copyFilePath As String
folderPath = Application.ActiveWorkbook.path
myPath = Application.ActiveWorkbook.FullName
SharePointLib = "https://company.com/folder/subfoler"
copyPath = folderPath + "\copyPath"
MsgBox "This is the folderPath = " & folderPath & vbNewLine & "This is the filepath = " & myPath & vbNewLine & "The copyPath is = " & copyPath
If Not FolderExists(copyPath) Then
FolderCreate (copyPath)
End If
SharePointLib = SharePointLib & FileNameWithExt(myPath)
ThisWorkbook.SaveCopyAs (copyPath)
Exit Sub
loadFailed:
UploadToSharepoint = False
End Sub
어떤 도움과 제안을 부탁드립니다. 고맙습니다.
을 :
이 시도 사용자 \ Jian.Chen2 \ 바탕 화면 \ Copypath'을 \,하지만 이름은 디렉토리에서 이미 사용중인 당신을 만들어진. – YowE3K