Hello,
Can any one of you please help me in solving my problem.
I need a Macro, which captures the data from Excel and writes in .txt file. I am missing something in my code..please check..
appreciate your help in advance.
Can any one of you please help me in solving my problem.
I need a Macro, which captures the data from Excel and writes in .txt file. I am missing something in my code..please check..
appreciate your help in advance.
Code:
Option Explicit
Sub EXPORTFallon()
Dim fPath As String
Dim fName As String
Application.DisplayAlerts = False
Application.ScreenUpdating = False
fPath = "D:\Local Disk (D)\Temp" 'remember final \ in this string
fName = "FALLONGRPS.txt-" & Format(Date, "MM.DD.YYYY")
Range("A2:S2").Copy
Workbooks.Add
Range("A2:S2").PasteSpecial xlPasteValuesAndNumberFormats
Columns("A:A").ColumnWidth = 3
Columns("B:B").ColumnWidth = 15
Columns("C:C").ColumnWidth = 60
Columns("D:D").ColumnWidth = 60
Columns("E:E").ColumnWidth = 60
Columns("F:F").ColumnWidth = 30
Columns("G:G").ColumnWidth = 2
Columns("H:H").ColumnWidth = 9
Columns("I:I").ColumnWidth = 15
Columns("J:J").ColumnWidth = 8
Columns("K:K").ColumnWidth = 8
Columns("L:L").ColumnWidth = 8
Columns("M:M").ColumnWidth = 15
Columns("N:N").ColumnWidth = 15
Columns("O:O").ColumnWidth = 1
Columns("P:P").ColumnWidth = 2
Columns("Q:Q").ColumnWidth = 1
Columns("R:R").ColumnWidth = 10
Columns("S:S").ColumnWidth = 391
'Rows(2).Insert xlShiftDown
'Range("A2:S2").Value = [{"Record Type","Sponsor Number","Sponsor Name","Address1","Address2","City","State","Zip","Phone","Benefit Plan Eff Date","Effective Date","Term Date","Till R2"}]
ActiveWorkbook.SaveAs Filename:=fPath & fName, FileFormat:=xlTextPrinter
ActiveWorkbook.Close False
Name fPath & fName As fPath & fName & ".dbf"
Application.ScreenUpdating = True
MsgBox "Done"
End Sub
Attachments
Last edited by a moderator: