DMS500Tech
Technical User
I give up.
I have looked and serched this web site for 3 days thru 1000's of titles and dozens of code snippets and can't find what I need.
Myself and an intern put together the following code last summer (I am not a programmer it is more like I hack code together until it works). Well I have ran into a big problem the query I am extracting the data from has grown from 50 some thousand records to over 200,000 records so I have far exceeded Excels 65536 row limit.
What I need to do is convert the following Excel VBA code so that it will work the same way in Access. I can't seem to find any examples of what it is that needs to be changed or how to change it.
-------------------------------------------------
CODE AS IT IS NOW
-------------------------------------------------
Option Explicit
Sub Extract_DN_and_LEN_from_a_text_files()
'
' populate Macro
'If there are coloumns that you dont want, comment it out in the code
Dim intOutFile As String
intOutFile = FreeFile
Dim RecordNum As Long
String
Open "C:\TEMP\CR16_0.TXT" For Input As #intOutFile ' Enter path of input file
RecordNum = 1
Dim LinesFromFile, NextLine As String
' code to check if the workbbok is open and if the contents of the workbook are protected
If ActiveWorkbook Is Nothing Then Exit Sub ' no active workbook
If ActiveWorkbook.ProtectStructure Then
MsgBox ActiveWorkbook.Name & " is protected.", vbCritical, "cannot overwrite."
Close intOutFile
Exit Sub
End If
Workbooks("RESULTS.xls").Worksheets("Sheet1").Activate
With ThisWorkbook.Worksheets("sheet1")
Do Until EOF(intOutFile)
Line Input #intOutFile, NextLine
If Mid(NextLine, 1, 3) = "LEN" Then
LinesFromFile = Mid(NextLine, 10, 16)
RecordNum = RecordNum + 1
.Cells(RecordNum, 1) = LinesFromFile
ElseIf Mid(NextLine, 1, 3) = "DN " Then
LinesFromFile = Mid(NextLine, 4, 10)
.Cells(RecordNum, 2) = LinesFromFile
End If
Loop
End With
Close intOutFile
End Sub
---------------------------------------------------
HERE IS A SAMPLE OF THE QUERY
---------------------------------------------------
LEN: ABCD 01 0 11 46
TYPE: SINGLE PARTY LINE
DN 4055551234 LCC 1FR SIG DT LNATTIDX 0
XLAPLAN KEY : 405_POTS_0 RATEAREA KEY : OKCY_L536_0
IBN TYPE: STATION
CUSTGRP: RESGRP SUBGRP: 0 NCOS: 0
CARDCODE: RDTLSG GND: N PADGRP: STDLN BNV: NL MNO: N
PM NODE NUMBER : 115
PM TERMINAL NUMBER : 1147
OPTIONS:
LCDR COD DGT PIC 6269 Y LPIC 6269 Y
RES OPTIONS:
CNDB NOAMA CND NOAMA CNAMD NOAMA ACRJ INACT
OFFICE OPTIONS:
U3WC AIN LNPTRIG
---------------------------------------------------
If anyone can help with this I would be very gratefull
I have looked and serched this web site for 3 days thru 1000's of titles and dozens of code snippets and can't find what I need.
Myself and an intern put together the following code last summer (I am not a programmer it is more like I hack code together until it works). Well I have ran into a big problem the query I am extracting the data from has grown from 50 some thousand records to over 200,000 records so I have far exceeded Excels 65536 row limit.
What I need to do is convert the following Excel VBA code so that it will work the same way in Access. I can't seem to find any examples of what it is that needs to be changed or how to change it.
-------------------------------------------------
CODE AS IT IS NOW
-------------------------------------------------
Option Explicit
Sub Extract_DN_and_LEN_from_a_text_files()
'
' populate Macro
'If there are coloumns that you dont want, comment it out in the code
Dim intOutFile As String
intOutFile = FreeFile
Dim RecordNum As Long
String
Open "C:\TEMP\CR16_0.TXT" For Input As #intOutFile ' Enter path of input file
RecordNum = 1
Dim LinesFromFile, NextLine As String
' code to check if the workbbok is open and if the contents of the workbook are protected
If ActiveWorkbook Is Nothing Then Exit Sub ' no active workbook
If ActiveWorkbook.ProtectStructure Then
MsgBox ActiveWorkbook.Name & " is protected.", vbCritical, "cannot overwrite."
Close intOutFile
Exit Sub
End If
Workbooks("RESULTS.xls").Worksheets("Sheet1").Activate
With ThisWorkbook.Worksheets("sheet1")
Do Until EOF(intOutFile)
Line Input #intOutFile, NextLine
If Mid(NextLine, 1, 3) = "LEN" Then
LinesFromFile = Mid(NextLine, 10, 16)
RecordNum = RecordNum + 1
.Cells(RecordNum, 1) = LinesFromFile
ElseIf Mid(NextLine, 1, 3) = "DN " Then
LinesFromFile = Mid(NextLine, 4, 10)
.Cells(RecordNum, 2) = LinesFromFile
End If
Loop
End With
Close intOutFile
End Sub
---------------------------------------------------
HERE IS A SAMPLE OF THE QUERY
---------------------------------------------------
LEN: ABCD 01 0 11 46
TYPE: SINGLE PARTY LINE
DN 4055551234 LCC 1FR SIG DT LNATTIDX 0
XLAPLAN KEY : 405_POTS_0 RATEAREA KEY : OKCY_L536_0
IBN TYPE: STATION
CUSTGRP: RESGRP SUBGRP: 0 NCOS: 0
CARDCODE: RDTLSG GND: N PADGRP: STDLN BNV: NL MNO: N
PM NODE NUMBER : 115
PM TERMINAL NUMBER : 1147
OPTIONS:
LCDR COD DGT PIC 6269 Y LPIC 6269 Y
RES OPTIONS:
CNDB NOAMA CND NOAMA CNAMD NOAMA ACRJ INACT
OFFICE OPTIONS:
U3WC AIN LNPTRIG
---------------------------------------------------
If anyone can help with this I would be very gratefull