Importing from a CSV file

skadiet

New Member
Joined
Aug 31, 2006
Messages
3
I am trying to pull in data from a CSV file and have it write it out in a different program. I use the "Open [filename] For Output as #1" format where the filename defined as a string.

It imports the data but when it writes it to the other program it sometimes loses text. For example if the value in the CSV file is "1234" it works perfectly. However if the value in the CSV file is "128z6" it will only get the "128" before the text. Is there anyway it can just accept the text as is? What is going on?
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Hey. here is the code. Please advise why it is only getting numeric input from CSV and not text. Thanks.

Dim ifile, ofile As String
Dim i1, i2, i3, i4, i5, i6, i7, i8, i9, i10, i11, i12, i13, i14, i15, i16, i17 As String
Dim alldone As Boolean, counter As Integer, icounter As String

' Input and Output Files
ifile = "F:\MY DOCUMENTS\EXCEL\test.csv"
ofile = "F:\MY DOCUMENTS\EXCEL\myTestOut.csv"
Open ifile For Input As #1
Open ofile For Output As #2
alldone = False
counter = 0

Write #2, "Start", Date, Time()

'---- loop -----
Do Until EOF(1)

beginning:
If Not alldone Then
Input #1, i1, i2, i3, i4, i5, i6, i7, i8, i9, i10, i11, i12, i13, i14, i15, i16, i17
Else
GoTo closeup
End If

If EOF(1) Then
alldone = True
' GoTo closeup
End If

With Session
'---------Code that doesn’t output letters and numbers ------------
.TransmitANSI i1 'Need to figure this out
.TransmitTerminalKey rcIBMTabKey

.TransmitANSI i2
.TransmitTerminalKey rcIBMTabKey

‘ and so on

End With

Loop
 
Upvote 0

Forum statistics

Threads
1,226,588
Messages
6,191,888
Members
453,684
Latest member
Gretchenhines

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