技術(shù) 點
- 技術(shù)
- 點
- V幣
- 點
- 積分
- 7288
|
4#
發(fā)表于 2009-3-17 10:04:40
|
只看該作者
本帖最后由 Grant 于 2009-3-17 10:09 編輯
1、如果我想每次僅選擇待導(dǎo)入數(shù)據(jù)文件夾下的一個csv文件,代碼如何更改呢?
更改列表框?qū)傩?多重選擇=無
2.不刪除原文件夾csv
Dim mycount As Long
Dim I As Integer
mycount = Me.List1.ListCount '列數(shù)
If mycount = 0 Then
MsgBox "導(dǎo)入完畢!'待導(dǎo)入的數(shù)據(jù)'文件夾中已經(jīng)沒有文件可以導(dǎo)入!"
MsgBox "a"
Exit Sub
End If
For I = 1 To mycount
Dim cur_path As String
cur_path = CurrentProject.Path & "\待導(dǎo)入數(shù)據(jù)\" '被導(dǎo)入的csv文件存放路徑
out_path = CurrentProject.Path & "\已導(dǎo)入數(shù)據(jù)\" '已導(dǎo)入的csv文件存放路徑
Dim csv_name As String
csv_name = Me.List1.ItemData(mycount - 1) '要導(dǎo)入的文件名:從最后一個開始導(dǎo)入
Call ReadCSVFile(cur_path, csv_name) '調(diào)用模塊
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
fso.MoveFile cur_path & csv_name, out_path & csv_name
'取消fso后即可.
Me.List1.RemoveItem csv_name ' '從原列表中刪除
mycount = mycount - 1
Next I
MsgBox "導(dǎo)入完成", vbInformation, "提示!" |
|