- 帖子
- 976
- 主題
- 7
- 精華
- 0
- 積分
- 1018
- 點名
- 0
- 作業系統
- Win10
- 軟體版本
- Office 2016
- 閱讀權限
- 50
- 性別
- 男
- 註冊時間
- 2013-4-19
- 最後登錄
- 2026-5-26
|
回復 3# zz0660
另一個想法,讓使用者選取檔案(可同時選擇多個),請測試看看,謝謝。
Sub test1()
Dim fs, f, R As Range, fc%, x%
Application.ScreenUpdating = False
Set fs = CreateObject("Scripting.FileSystemObject")
With Application.FileDialog(msoFileDialogOpen)
.InitialFileName = "D:\"
.AllowMultiSelect = True
.Show
fc = .SelectedItems.Count
If fc = 0 Then Exit Sub
For x = 1 To fc
FPath = .SelectedItems(x)
Set f = fs.OpenTextFile(FPath, 2) '8:保留原資料;2:清除原資料
For Each R In [A2:A32]: f.WriteLine (R): Next
f.Close
Next
End With
Set fs = Nothing: Set f = Nothing
Application.ScreenUpdating = True
End Sub |
|