miller1975
Programmer
I had posted a thread yesterday to import a .txt file to excel and then move it to a new location. But for some reason the code was not working. So I made a macro in excel to import the txt file.
But I still cant automatic it in Vb. Can anyone please help me figure this out.
I need to import the txt to excel and then move the saved .xls file to a new folder.
My sample values are
target - c:\excel\data.txt
destination - c:\excel\import\data.xls
But I still cant automatic it in Vb. Can anyone please help me figure this out.
I need to import the txt to excel and then move the saved .xls file to a new folder.
My sample values are
target - c:\excel\data.txt
destination - c:\excel\import\data.xls
Code:
Sub export()
'
' export Macro
Workbooks.OpenText FileName:="C:\excel\data.txt", Origin:=xlWindows, _
StartRow:=1, DataType:=xlDelimited, TextQualifier:=xlDoubleQuote, _
ConsecutiveDelimiter:=False, Tab:=False, Semicolon:=False, Comma:=True _
, Space:=False, Other:=False, FieldInfo:=Array(Array(1, 1), Array(2, 1), _
Array(3, 1), Array(4, 1), Array(5, 1), Array(6, 1), Array(7, 1), Array(8, 1), Array(9, 1))
ChDir "C:\excel\export"
ActiveWorkbook.SaveAs FileName:="C:\excel\export\data.xls", FileFormat:= _
xlNormal, Password:="", WriteResPassword:="", ReadOnlyRecommended:=False _
, CreateBackup:=False
End Sub