I am getting the error shown in the attached html file and cannot figure out how to fix it. I have seen the comments by broomee9 and BullmanTech but they had already been considered and taken care of. When the spreadsheet opens, Workbook_Open() runs the procedure called CreateXMLFile from module CreateXMLFiles and works as expected. Once the procedure runs it is supposed to wait one minute and run the module CreateXMLFiles again and then keep looping “forever”. However, when it loops the first time I get the error message.
The code in this spreadsheet is an attempt to do what I would like to do in my open question called: What is the reason for an “Unexpected error 50290…” in VB6 code?. In that spreadsheet I do not use the “Application.OnTime Now + TimeValue("00:01:00"), "CreateXMLFiles"” statement since the VB code does the looping.
' This code is in XMLGTLInput
Public Sub Workbook_Open()
' This code is in Module CreateXMLFiles
Public Sub CreateXMLFile()
Dim I As Long, J As Long, K As Long
Dim InArray(40) As String
' Select sheet, columns and clear columns we are writing to.
J = 0
K = 1
' Import File Data
Open "\\ECCNT\from_ems\GTL_Data\set_generator.txt" For Input As #1
Do While Not EOF(1)
Line Input #1, InArray(J)
Range("C2:C40").Cells(K, 1).Value = Mid(InArray(J), 1, 11)
Range("H2:H40").Cells(K, 1).Value = Mid(InArray(J), 12, 4)
Range("I2:I40").Cells(K, 1).Value = Mid(InArray(J), 17, 4)
K = K + 1
J = J + 1
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
' Close and exit while saving changes
Application.DisplayAlerts = False
Application.OnTime Now + TimeValue("00:01:00"), "CreateXMLFiles"