Vgabond
Board Regular
- Joined
- Jul 22, 2008
- Messages
- 197
Hi Gurus
I have recorded a macro and I need help to fix some of the code.
Currently I have to change the file name ( D:\Work\2017\June2017.txt") in order for macro to pick the file and change it to Excel format. How can I run the macro and it will convert the entire file ?
I have recorded a macro and I need help to fix some of the code.
Code:
Sub ConvertExcel()'
' ConvertExcel Macro
'
'
Workbooks.OpenText Filename:= _
"D:\Work\2017\June2017.txt", Origin:= _
437, StartRow:=1, DataType:=xlDelimited, TextQualifier:=xlDoubleQuote, _
ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=False, Comma:=False _
, Space:=False, Other:=True, OtherChar:="|", 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), Array(10, 1), Array(11, 1), Array(12, 1), Array(13, 1), Array(14, 1), Array(15 _
, 1), Array(16, 1), Array(17, 1), Array(18, 1), Array(19, 1), Array(20, 1), Array(21, 1), _
Array(22, 1), Array(23, 1), Array(24, 1), Array(25, 1), Array(26, 1), Array(27, 1), Array( _
28, 1), Array(29, 1), Array(30, 1), Array(31, 1), Array(32, 1), Array(33, 1), Array(34, 1), _
Array(35, 1), Array(36, 1), Array(37, 1), Array(38, 1), Array(39, 1), Array(40, 1), Array( _
41, 1), Array(42, 1), Array(43, 1), Array(44, 1), Array(45, 1), Array(46, 1), Array(47, 1), _
Array(48, 1), Array(49, 1), Array(50, 1), Array(51, 1), Array(52, 1), Array(53, 1), Array( _
54, 1)), TrailingMinusNumbers:=True
Application.Goto Reference:="Convert_To_Excel!ConvertExcel"
ActiveWorkbook.SaveAs Filename:= _
"D:\Work\Telesales\Calling List\Total_Contacted\2017\June2017.xlsx", _
FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False
Application.Goto Reference:="Convert_To_Excel!ConvertExcel"
End Sub
Currently I have to change the file name ( D:\Work\2017\June2017.txt") in order for macro to pick the file and change it to Excel format. How can I run the macro and it will convert the entire file ?