M
muybn
A macro I'm creating (see partial code below) reads tab-delimited fields from
a text file. The strange thing is that after I shut it down then start it up
again for testing, I receive the message "This key is already associated with
an element of this collection"--almost as if the process is kept in memory
from the previous session. The hangup occurs on the line that reads
"arrHeaderNames(intCtr)" at the end.
Then, even more strange, when I bump the yellow highlighted step indicator
back up about three lines to "Line Input #1," it runs OK.
Thanks in advance for any thoughts.
'get some key values from source file and assign them to main variables
Open strPathWkFile For Input As #1
Line Input #1, strScrap
arrHeaderNames = Split(strScrap, Chr(9))
For intCtr = LBound(arrHeaderNames) To UBound(arrHeaderNames)
colHeader.Add Item:=Trim(str(intCtr)), Key:=arrHeaderNames(intCtr)
Next intCtr
intCtr = 0
Do While Not EOF(1)
intCtr = intCtr + 1
Line Input #1, strScrap
arrFieldData = Split(strScrap, Chr(9))
strLead_ID = arrFieldData(Val(colHeader.Item("Lead_ID")))
I even tried changing the value of intCtr in the troubled line from 0 to 1
but to no avail.
a text file. The strange thing is that after I shut it down then start it up
again for testing, I receive the message "This key is already associated with
an element of this collection"--almost as if the process is kept in memory
from the previous session. The hangup occurs on the line that reads
"arrHeaderNames(intCtr)" at the end.
Then, even more strange, when I bump the yellow highlighted step indicator
back up about three lines to "Line Input #1," it runs OK.
Thanks in advance for any thoughts.
'get some key values from source file and assign them to main variables
Open strPathWkFile For Input As #1
Line Input #1, strScrap
arrHeaderNames = Split(strScrap, Chr(9))
For intCtr = LBound(arrHeaderNames) To UBound(arrHeaderNames)
colHeader.Add Item:=Trim(str(intCtr)), Key:=arrHeaderNames(intCtr)
Next intCtr
intCtr = 0
Do While Not EOF(1)
intCtr = intCtr + 1
Line Input #1, strScrap
arrFieldData = Split(strScrap, Chr(9))
strLead_ID = arrFieldData(Val(colHeader.Item("Lead_ID")))
I even tried changing the value of intCtr in the troubled line from 0 to 1
but to no avail.