- 帖子
- 561
- 主題
- 160
- 精華
- 0
- 積分
- 725
- 點名
- 0
- 作業系統
- WINDOWS
- 軟體版本
- xp
- 閱讀權限
- 50
- 性別
- 男
- 來自
- 桃園
- 註冊時間
- 2014-9-10
- 最後登錄
- 2026-2-12
  
|
Dear ALL 大大:
1.如圖一目前可以選取單一檔案成功上傳,
2.但是改成多檔後上傳會沒有動作,
2.1目前單檔選曲寫法:
source = Application.GetOpenFilename
2.2目前多檔選取寫法:
'source = Application.GetOpenFilename(MultiSelect:=True)
3.請教如何修改為多檔後上傳至目的檔.煩不吝賜教. THANKS
圖一
Sub test()
Dim folder As String '資料
Dim source As String '來源檔
Dim dest As String '目的檔
Dim p As Integer
Dim s As Integer
Dim i As Long
folder = "D:\ABC" '存取目的位置
source = Application.GetOpenFilename '來源
If source = "False" Then: MsgBox "上傳失敗,請選取正確來源檔案。": Exit Sub
p = 1
i = 1
Do Until p = 0
p = InStr(i, source, "\", 1)
If p = 0 Then Exit Do
s = p
i = p + 1
Loop
dest = folder & Mid(source, s, Len(source))
If Dir(dest) <> "" Then
MsgBox msg1
Else
FileCopy source, dest
MsgBox source & " 已上傳。"
End If
Exit Sub
End Sub |
|