From: vepha on 9 Dec 2009 23:51 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 -- " Dont mess around so much, do something usefull like making the world a better place, like helping people who really need help, like being the ace instead of an empty face! "
From: Crystal (strive4peace) on 10 Dec 2009 02:40 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 :) * vepha wrote: > 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
|
Pages: 1 Prev: open and close form with one OnClick Next: RQuestion on Form Record Selector Bar |