사용자가 파일을 선택하고 다른 위치 (예 : 공유 드라이브)에 업로드하도록 선택하려고합니다. 이름 함수를 사용하고 있지만 파일 이름을 가져 오는 데 문제가 있다는 것을 깨닫고 "toPath"에 넣는 것은 사용자에게 달려 있기 때문입니다. 아래는 완성 된 코드입니다. 조언이나 제안 사항이 도움이된다면 알려주세요.VBA에서 동적 파일 재배치
동시에, 내 코드가 누군가가 그 문제를 해결하는 데 도움이되기를 바랍니다. 감사합니다
는 업로드 할 파일을 선택하려면 :
Private Sub Command2_Click()
Dim fDialog As Variant
' Clear listbox contents. '
Me.Path1.Value = ""
' Set up the File Dialog. '
Set fDialog = Application.FileDialog(msoFileDialogFilePicker)
With fDialog
' Allow user to make multiple selections in dialog box '
.AllowMultiSelect = False
' Set the title of the dialog box. '
.Title = "Please select one file"
' Clear out the current filters, and add our own.'
.Filters.Clear
.Filters.Add "All Files", "*.*"
' Show the dialog box. If the .Show method returns True, the '
' user picked at least one file. If the .Show method returns '
' False, the user clicked Cancel. '
If .Show = True Then
'add selected path to text box
Me.Path1.Value = .SelectedItems(1)
Else
MsgBox "No File Selected."
End If
End With
End Sub
파일을 업로드 할 업로드 경로를 선택하려면
Private Sub Command10_Click()
Dim FromPath As String
Dim ToPath As String
Dim fDialog2 As Variant
' Clear listbox contents. '
Me.Path2.Value = ""
FromPath = Me.Path1
ToPath = Me.Path2
' Set up the File Dialog. '
Set fDialog2 = Application.FileDialog(msoFileDialogFolderPicker)
With fDialog2
If .Show = True Then
'add selected path to text box
Me.Path2.Value = .SelectedItems(1)
Else
MsgBox "No file uploaded."
End If
End With
Name FromPath As ToPath & "\" & 'ummmmmmmmmmm I am stucked :(
MsgBox "You can find the files and subfolders from " & FromPath & " in " & ToPath
End Sub
끝으로 추가 할 수있는 파일이 재배치하는 유형,하지만 확실하지 않다 너는 필요해. –
사용자가 이동 된 파일의 이름을 선택하게 하시겠습니까? 또는 이전 파일과 동일한 이름으로 사용 하시겠습니까? –