View Single Post
  #4  
Old June 4th, 2010, 03:32 PM posted to microsoft.public.excel.worksheet.functions
Jackpot
external usenet poster
 
Posts: 28
Default Import old dos sequencial data

You can try out the below macro to read this file and place this to excel
activesheet. If you are new to macros.. (Please note to change the
recordlength as needed)

--Set the Security level to low/medium in (Tools|Macro|Security).
--From workbook launch VBE using short-key Alt+F11.
--From menu 'Insert' a module and paste the below code.
--Get back to Workbook.
--Run macro from Tools|Macro|Run selected macro()


Sub Macro2()
Dim intFile As Integer, strFile As String
Dim intLen As Integer, lngRow As Long

strFile = "c:\test.txt"
intLen = 10

intFile = FreeFile
Open strFile For Input As #intFile
Do While Not EOF(intFile)
lngRow = lngRow + 1
Range("A" & lngRow) = Input(intLen, #intFile)
Loop
Close intFile
End Sub


"Rich Stone" wrote:

I have an old database that stored it's data in a sequencial format with
fixed lengths for each field. As Windows 7 64-bit no longer allows the
running of the database I need to access the data in another way so wish to
import it to excel. I can get as far as marking the first record's field
lengths but there does not seem to be a way of marking the end of the record.
Instead it leaves the rest of the data in the final field!

Can anyone suggest the best way of doing this? Thank you.