Abrir libro excel usando comodines

juanpy

New Member
Joined
Aug 21, 2014
Messages
17
Estimados,

La idea es abrir un libro excel desde una ubicacion pre definida, cuyo nombre esta estructurado de la siguiente manera.

LibroBanco201409051345.xlsx
|ParteFija|-Fecha--|Hora

La parte "LibroBanco" es fija, no asi la fecha y hora que son variables

Existen varios archivos en el directorio con este nombre, el que yo necesito abrir, siempre sera el ultimo generado.

Estube probando con ?? o **, pero no sirve (LibroBanco????????????.xlsx).

¿Alguien sabe como lo puedo hacer?

Muchas gracias.
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Hi,

Sorry, no hablo Espagnol.

Try this:
Code:
Sub xx()
    Dim FileTemp As String, FileName As String
    FileTemp = Dir("C:\Users\RickXL\Documents\@Excel\MasterFolder\LibroBanco*.xlsx")     '  <=== Your Folder
    Do While FileTemp <> ""
        FileName = FileTemp
        FileTemp = Dir
    Loop
    Debug.Print FileName   '  <=== Answer
End Sub

The value of FileName will be the most recent file.

Regards,
 
Upvote 0

Forum statistics

Threads
1,214,412
Messages
6,119,365
Members
448,888
Latest member
Arle8907

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top