Hi all,
I am importing a very big .txt file through an agent that has the following code. I think I have declared all the variables correctly. I still get these 2 errors “Overflow, error #:6 error line: 72” and the “IMport error”. These two errors keep flickering on the status bar at the bottom alternatively.
The error is on the following 3 lines below
"Redim Preserve y(i)
y(i) = c
Call rtitem.AppendText( y(i) )"
Any help is greatly appreciated.
Here is my code.
Sub Initialize
Dim c As Variant
Dim i As Long
Dim allrecs As Long
Dim x As Variant
Dim y() As Variant
'Dim tmp As String
'Dim tmp1 As String
'Dim eval As Variant
Dim session As New NotesSession
Dim workspace As New NotesUIWorkspace
'Dim primkeypos As Long
Dim db As NotesDatabase
Dim doc As NotesDocument
Dim uidoc As NotesUIDocument
Dim item As NotesItem
Dim rtitem As NotesRichTextItem
Dim richStyle As NotesRichTextStyle
Set db = session.CurrentDatabase
tmp = “PRIMARY KEY”
tmp1 = “”
Set doc = New Notesdocument( db )
doc.form=“frmCappData”
Set richStyle = session.CreateRichTextStyle
richStyle.NotesFont = FONT_COURIER
richStyle.FontSize = 8
Set rtitem = New NotesRichTextItem( doc, “body” )
Call rtitem.AppendStyle(richStyle)
On Error Goto ErrorExit
'Stop
'Open “D:\TRFMFRAME\capp.txt” For Input As #1
Open “C:\EB\capp.txt” For Input As #1
c = " "
x = " "
allrecs = 0
i = 1 'Start at 0 here so when we add 1,we’ll reference the first element
Do Until Eof(1)
'i = i + 1
allrecs = allrecs + 1
'fake input - This do until eof routine is to get the total number of records in the file. The actual inuput is in the for loop
'below where variable c is used. This workaround is to skip the last “----” line so that a new document is not created there.
Line Input #1, x
Loop
Seek 1, 1
For i = 1 To (allrecs -1)
Line Input #1, c
If Left$(c, 10) = “==========” Then
Set doc = db.CreateDocument
doc.form=“frmCappData”
Set richStyle = session.CreateRichTextStyle
richStyle.NotesFont = FONT_COURIER
richStyle.FontSize = 8
Set rtitem = New NotesRichTextItem( doc, “body” )
Call rtitem.AppendStyle(richStyle)
End If
If Left$(c, 10) <> “==========” Then
Redim Preserve y(i)
y(i) = c
Call rtitem.AppendText( y(i) )
rtitem.AddNewLine( 1 )
End If
If Left$(c, 11) = “PRIMARY KEY” Then
doc.DrPcVr = Mid$(c, 12, 30)
doc.PartNumber = Mid$(c, 45, 15)
Call doc.Save( True, True )
End If
'Stop
Call doc.Save( True, True )
Print i
Next i
'Loop
Yield 'This is just to make sure we allow the OS to do something if it needs to
Call doc.Save( True, True )
Close #1
Exit Sub
ErrorExit:
Print “Import Error” Print “Error: " Error(), " Err:” Err(), " Erl:" Erl()
Resume Next
End Sub
Thank you,
Archana Mulay