Save Imported File to Directory

creyn

Board Regular
Joined
Sep 16, 2016
Messages
127
Below is the code I am using to import a text file to a table in Access. However, is there a way to Save the file I just imported to the same Directory?

Option Compare Database

Public Sub Command0_Click()
Dim MyFolder As String
Dim MyFile As String
Dim MyFolder2 As String
Dim DQ As String
Dim MyData As String
Dim myQueryName As String
Dim myExportFileName As String

DoCmd.SetWarnings False
DoCmd.RunSQL "Delete * from Import_Data"
MyFolder2 = "S:\zCorey\TDD File Cleanup\Sample Files\New Version"
MyFile = Dir(MyFolder2 & "\*.txt")
Do While MyFile <> ""
DoCmd.SetWarnings False
DoCmd.RunSQL "Delete * from Import_Data"
DoCmd.TransferText acImportDelim, "Import Specification", "Import_Data", MyFile, True
FileCopy MyFile, "S:\zCorey\TDD File Cleanup\Sample Files\New Version" & [MyFile]
DoCmd.TransferText transferType:=acExportDelim, SpecificationName:="Export Specification", TableName:="Import_Data", _
FileName:="S:\zCorey\TDD File Cleanup\Sample Files\New Version" & [MyFile], hasfieldnames:=True
DoCmd.SetWarnings False
MyFile = Dir
Loop
End Sub
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.

Forum statistics

Threads
1,215,527
Messages
6,125,336
Members
449,218
Latest member
Excel Master

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top