financial details copy to a txt file

beginerSL

New Member
Joined
Mar 1, 2015
Messages
9
Type ttuRecord ' Define user-defined type.
Foracid As String * 16
DrCr As String * 1
Amount As String * 17
Filler As String * 10
TranPart As String * 20
Partition As String * 12
Date As String * 10

End Type




Sub Button1_Click()
Dim ttu As ttuRecord
Dim jstr As String
Dim amt As String


Open "ttumCCD.txt" For Output As #1
' Close before reopening in another mode.
RowIndex = 2
While Worksheets("TTUM").Cells(RowIndex, 1) > 0
ColIndex = 1
With ttu
.Foracid = Format(Worksheets("TTUM").Cells(RowIndex, ColIndex), "000000000000")
ColIndex = ColIndex + 1
curr = "LKR"
brcode = Mid(.Foracid, 2, 3)
Spac = " "
.DrCr = Worksheets("TTUM").Cells(RowIndex, ColIndex)
ColIndex = ColIndex + 1
amt = Format(Worksheets("TTUM").Cells(RowIndex, ColIndex), "#############0.00")
.Amount = Space(16 - Len(amt)) & amt
ColIndex = ColIndex + 1
.Filler = Mid(Worksheets("TTUM").Cells(RowIndex, ColIndex), 1, 10)
ColIndex = ColIndex + 1
.TranPart = Mid(Worksheets("TTUM").Cells(RowIndex, ColIndex), 1, 20)
ColIndex = ColIndex + 1
.Partition = Format(Worksheets("TTUM").Cells(RowIndex, ColIndex), "000000000000")
Spec1 = " "
ColIndex = ColIndex + 1
.Date = Mid(Worksheets("TTUM").Cells(RowIndex, ColIndex), 1, 10)

jstr = .Foracid & .DrCr & .Amount & .Filler & .Date & Spac & .TranPart & Spec1 & .Partition
Print #1, jstr
End With

RowIndex = RowIndex + 1
Wend


Close #1


MsgBox "File Created: ttumCCD.txt" & vbCrLf & _
RowIndex - 2 & " Records Written"
End Sub


​This is the macro codes i write for creating a txt file name as ttumCCD.txt . But when i run the macro that msg box appear as file sucesfully created but no file created any where. I need to check for any fault if any with this coding.
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.

Forum statistics

Threads
1,203,506
Messages
6,055,800
Members
444,825
Latest member
aggerdanny

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