Busqueda de archivos y abrirlos

14/06/2007 - 09:47 por Thebigmik | Informe spam
Hola a todos, lo que quiero hacer es crear un archivo de excel que al
abrirlo ejecute el código vba que busque los archivos que esten en ese
mismo directorio que terminen en "SLM" y los abra para despues seguir
tratandolos.

|Carpeta de Trabajo|

¿Como buscar los archivos que termine en SLM? (me da igual si es con
file system object)

Gracias

Preguntas similare

Leer las respuestas

#1 KL
14/06/2007 - 11:04 | Informe spam
Hola Thebigmik,

Prueba esto:

Sub test()
Dim strName As String
Dim strPath As String
Dim arrMatrix() As String
Dim i As Long

strPath = ThisWorkbook.Path & "\"
strName = Dir(strPath & "*SLM.xls")

ReDim arrMatrix(0) As String
Do While Len(strName) > 0
'visualizamos los nombres en la ventana Immediate
Debug.Print strPath & strName
'recogemos los nombres en una matriz
ReDim Preserve arrMatrix(UBound(arrMatrix) + 1)
arrMatrix(UBound(arrMatrix)) = strPath & strName
strName = Dir
Loop
ReDim Preserve arrMatrix(UBound(arrMatrix) - 1)
End Sub
Respuesta Responder a este mensaje
#2 Thebigmik
14/06/2007 - 11:47 | Informe spam
On 14 jun, 11:04, "KL" wrote:
Hola Thebigmik,

Prueba esto:

Sub test()
Dim strName As String
Dim strPath As String
Dim arrMatrix() As String
Dim i As Long

strPath = ThisWorkbook.Path & "\"
strName = Dir(strPath & "*SLM.xls")

ReDim arrMatrix(0) As String
Do While Len(strName) > 0
'visualizamos los nombres en la ventana Immediate
Debug.Print strPath & strName
'recogemos los nombres en una matriz
ReDim Preserve arrMatrix(UBound(arrMatrix) + 1)
arrMatrix(UBound(arrMatrix)) = strPath & strName
strName = Dir
Loop
ReDim Preserve arrMatrix(UBound(arrMatrix) - 1)
End Sub



muchas gracias, lo probare cuando pueda, gracias KL
Respuesta Responder a este mensaje
#3 Thebigmik
21/06/2007 - 12:16 | Informe spam
On 14 jun, 11:47, Thebigmik wrote:
On 14 jun, 11:04, "KL" wrote:





> Hola Thebigmik,

> Prueba esto:

> Sub test()
> Dim strName As String
> Dim strPath As String
> Dim arrMatrix() As String
> Dim i As Long

> strPath = ThisWorkbook.Path & "\"
> strName = Dir(strPath & "*SLM.xls")

> ReDim arrMatrix(0) As String
> Do While Len(strName) > 0
> 'visualizamos los nombres en la ventana Immediate
> Debug.Print strPath & strName
> 'recogemos los nombres en una matriz
> ReDim Preserve arrMatrix(UBound(arrMatrix) + 1)
> arrMatrix(UBound(arrMatrix)) = strPath & strName
> strName = Dir
> Loop
> ReDim Preserve arrMatrix(UBound(arrMatrix) - 1)
> End Sub

muchas gracias, lo probare cuando pueda, gracias KL- Ocultar texto de la cita -

- Mostrar texto de la cita -



Ahhh ya lo he probado y todo OK, gracias KL
email Siga el debate Respuesta Responder a este mensaje
Ads by Google
Help Hacer una preguntaRespuesta Tengo una respuesta
Search Busqueda sugerida