返回列表 上一主題 發帖

[發問] VBA可以做到設計彈出式窗讓使用者點選檔案以匯入的功能嗎?

回復 9# Hsieh


請教各位高手大大
小弟想要使用選擇檔案 並將選擇之檔案 複製到d:\test 資料夾裡
但是 FILECOPY "來源","D:\test"     的來源想用變數取代 卻一直出現錯誤
可以麻煩高手幫忙看一下需要如何修改才能符合順利跑下去
Private Sub CommandButton1_Click()

With Application.FileDialog(msoFileDialogOpen)
   .AllowMultiSelect = True
   .Show
   For i = 1 To .SelectedItems.Count
     Cells(i, 1) = .SelectedItems(i)
     MsgBox .SelectedItems(i)
     fs = .SelectedItems(i)

       ==> Private Sub CommandButton1_Click()

With Application.FileDialog(msoFileDialogOpen)
   .AllowMultiSelect = True
   .Show
   For i = 1 To .SelectedItems.Count
     Cells(i, 1) = .SelectedItems(i)
     MsgBox .SelectedItems(i)
     fs = .SelectedItems(i)

       fileCopy(fs,"d:\test")
   Next
End With
End SubfileCopy(fs,"d:\test")
   Next
End With
End Sub
感激

TOP

回復 11# shakeass

貼文失敗重貼一帖sorry
    請教各位高手大大
小弟想要使用選擇檔案 並將選擇之檔案 複製到d:\test 資料夾裡
但是 FILECOPY "來源","D:\test"     的來源想用變數取代 卻一直出現錯誤
可以麻煩高手幫忙看一下需要如何修改才能符合順利跑下去
Private Sub CommandButton1_Click()

With Application.FileDialog(msoFileDialogOpen)
   .AllowMultiSelect = True
   .Show
   For i = 1 To .SelectedItems.Count
     Cells(i, 1) = .SelectedItems(i)
     MsgBox .SelectedItems(i)
     fs = .SelectedItems(i)

       fileCopy(fs,"d:\test")
   Next
End With
End Sub

TOP

        靜思自在 : 信心、毅力、勇氣三者具備,則天下沒有做不成的事。
返回列表 上一主題