I have a problem, to see if you can help me.
I have several xml files, which I'm dealing with one by one. I take the first one I try and I keep his information and when I finish crossing it I go to the next, and so on until I no longer have more files to try.
The problem is that when I try to resize the matrix, it does not leave me, since it gives me a subindex error outside the interval. I do not know how to make the matrix grow every time I try a new file, but keeping the information. I detail what I have:
The variable Matrix () as Variant. I have it declared this way.
While MyFile <> ""
Workbooks("Fichero.xlsm").Activate
XMLFileName = Mydir & MyFile
Oxmlfile.Load (XMLFileName)
Set nodes = Oxmlfile.SelectNodes("//AINVOICELIST/*")
aux_node = nodes.Length 'Longitud del nodo
n = n + aux_node
j = 1
ReDim Preserve Matriz(n, 30)
n = 0
For Each node1 In nodes
y = 0
Matriz(n, y) = node1.SelectSingleNode("SC").nodeTypedValue()
Matriz(n, y + 1) = Fact & node1.SelectSingleNode("I").nodeTypedValue()
Matriz(n, y + 2) = node1.SelectSingleNode("DATE").nodeTypedValue()
n = n + 1
Next
Later I call a function
that is responsible for taking the treated file to another folder and start with the next one.
Traslado_fichero (MyFile)
MyFile = Dir(Path & MyExtension)
When I start to try the second file and try to resize the matrix, it is when I get the error. Right here ReDim Preserve Matriz(n, 30)
, it shows me the message "Subindice out of range"
Can you help me please? Thank you very much.