1
ห้อง MS Access / : ต้องการเปลี่ยนนามสกุลไฟล์หลังจากimport
« เมื่อ: 09 มี.ค. 64 , 15:02:37 »
แก้เป็นแบบนี้ครับ ในส่วนของ Import()
โค๊ด: [Select]
Sub Import()
Dim strPath As String
Dim strFile As String
Dim strTable As String
Dim StrFileName As String
Dim strextensionNew As String
strTable = "Table1"
strPath = "D:\textfile\"
strFile = Dir(strPath & "*.txt")
Do While strFile <> ""
StrFileName = strPath & strFile
DoCmd.TransferText acImportDelim, "", strTable, StrFileName, False
strextensionNew = Left(StrFileName, InStrRev(StrFileName, ".") - 1) & ".xxx"
If Len(Dir$(strextensionNew)) > 0 Then
Kill strextensionNew
End If
Name StrFileName As strextensionNew
strFile = Dir(strPath & "*.txt")
Loop
End Sub
โพสต์นี้ได้รับคำขอบคุณจาก: kapiak