Recuperar valores de un Array declarados en otro sub
publicado
Hola, buenas noches.
Tengo un problema, he declarado en una subrutina el Array OutArr(), y ahora que estoy trabajando en otra subrutina, para la cual necesito recuperar el valor dado a OutArr(2,Idx) pero no sé como hacerlo.
El fondo de todo esto es que he guardado en este array datos sobre los archivos contenidos en una carpeta, y luego mas adelante voy a necesitar estos datos otra vez.
[Public Sub Folder_List(TheFolders$, Idx As Long, OutArr)
Dim fso As Object, Folder As Object
Dim SubFol As Object, File As Object
On Error Resume Next
Set fso = CreateObject("Scripting.FileSystemObject")
Set Folder = fso.getfolder(TheFolders)
'Define the array where the data is going to be stored
For Each File In Folder.Files
Idx = Idx + 1
ReDim Preserve OutArr(1 To 8, 1 To Idx)
'Information about the process that the macro is working on
Application.StatusBar = "Lecture: " & File.Path
On Error Resume Next
'Assign data to each element of the Array
OutArr(1, Idx) = File.ParentFolder
OutArr(2, Idx) = File.Name
OutArr(5, Idx) = File.DateCreated
OutArr(6, Idx) = File.DateLastModified
OutArr(7, Idx) = File.Type
OutArr(8, Idx) = File.Size
On Error GoTo 0
Next
'Do the same operation with the subfolders located inside the Mother Folder
For Each SubFol In Folder.SubFolders
Folder_List SubFol.Path, Idx, OutArr
Next SubFol
Set fso = Nothing
Application.StatusBar = False
End Sub]
Gracias
Featured Replies
Archivado
Este tema está ahora archivado y está cerrado a más respuestas.
Hola, buenas noches.
Tengo un problema, he declarado en una subrutina el Array OutArr(), y ahora que estoy trabajando en otra subrutina, para la cual necesito recuperar el valor dado a OutArr(2,Idx) pero no sé como hacerlo.
El fondo de todo esto es que he guardado en este array datos sobre los archivos contenidos en una carpeta, y luego mas adelante voy a necesitar estos datos otra vez.
[Public Sub Folder_List(TheFolders$, Idx As Long, OutArr)
Dim fso As Object, Folder As Object
Dim SubFol As Object, File As Object
On Error Resume Next
Set fso = CreateObject("Scripting.FileSystemObject")
Set Folder = fso.getfolder(TheFolders)
'Define the array where the data is going to be stored
For Each File In Folder.Files
Idx = Idx + 1
ReDim Preserve OutArr(1 To 8, 1 To Idx)
'Information about the process that the macro is working on
Application.StatusBar = "Lecture: " & File.Path
On Error Resume Next
'Assign data to each element of the Array
OutArr(1, Idx) = File.ParentFolder
OutArr(2, Idx) = File.Name
OutArr(5, Idx) = File.DateCreated
OutArr(6, Idx) = File.DateLastModified
OutArr(7, Idx) = File.Type
OutArr(8, Idx) = File.Size
On Error GoTo 0
Next
'Do the same operation with the subfolders located inside the Mother Folder
For Each SubFol In Folder.SubFolders
Folder_List SubFol.Path, Idx, OutArr
Next SubFol
Set fso = Nothing
Application.StatusBar = False
End Sub]
Gracias