There are a couple of mistakes you made:
a) array indexes start at 0 (except you have stated otherwise)
so you have to adress your singlefile() array differently.
Also the for loop within Command2_Click() must start at 0Code:op = True singlefile(optime) = Text2.Text 'first set element 0 optime = optime + 1 'then increment counter
b) as you did not dim xlapp as an array, so xlapp(l) will invariably be an error. You couldCode:Fo l=0 to optime-1 ...
But this is only hinting the obvious technical errors. We do not know what you want to achieve exactly. Therefore there may be more flaws within your concept which are not as easy to spot.Code:Dim xlapp() as Excel.Application ... For l = 0 to optime - 1 ReDim xlapp(l) set xlapp(l) = openexcel(l, singlefile(l)) Next
optime = optime + 1




Reply With Quote