Move Files after import

  • Thread starter Thread starter vepha
  • Start date Start date
V

vepha

Hi Everyone,

I want to move all the imported files to another path instead of deleting.
here is the code i am using.

Private Sub Befehl457_Click()
On Error GoTo Err_Befehl457_Click
Dim strPathFile As String, strFile As String, strPath As String
Dim strTable As String
Dim blnHasFieldNames As Boolean

blnHasFieldNames = True

strPath = "Path"

strTable = "table"

strFile = Dir(strPath & "*.xls")
Do While Len(strFile) > 0
strPathFile = strPath & strFile
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, _
strTable, strPathFile, blnHasFieldNames

Kill strPathFile

strFile = Dir()
Loop
Exit_Befehl457_Click:
Exit Sub

Err_Befehl457_Click:
MsgBox Err.Description
Resume Exit_Befehl457_Click
End Sub

Thank and best regards
vepha
 
Hi vepha (what is your name?)

move the file and then use TransferSpreadsheet -- that way
you don't have to worry how long the file will be tied up by
TransferSpreadsheet before it can be released.

use the NAME command to rename and move files

~~~~ from Help:
Dim OldName, NewName
OldName = "OLDFILE": NewName = "NEWFILE" ' Define file names.
Name OldName As NewName ' Rename file.

OldName = "C:\MYDIR\OLDFILE": NewName = "C:\YOURDIR\NEWFILE"
Name OldName As NewName ' Move and rename file.
~~~~~~~~~~~~~~~~~~~~


Warm Regards,
Crystal
remote programming and training

http://MSAccessGurus.com

My Analyzer
.... the ultimate Data Dictionary Tool
by Crystal
http://www.AccessMVP.com/strive4peace/Dictionary

*
(: have an awesome day :)
*
 
Back
Top