(Solved) – ¿How to open a file with a partial name by using VBA?

(solved)-–-¿how-to-open-a-file-with-a-partial-name-by-using-vba?

I have a folder where I download several files from a mail that I getevery monday in order to generate a report. I’m triying to open a specific file of them by using its partial name because the file name change depending of the date

The file name that I try to open is:
A_114_2020_PROMOCIONESYCAMBIOSDEPRECIO_TABLA DE PRECIOS

This is my code

MainPath = "C:Usersalan.gutierrezDesktopARCHIVOS_MACROPROCESOSBAJAS_TEMPORALES"
fileName = Dir(MainPath & "PROMOCIONESYCAMBIOSDEPRECIO_TABLA DE PRECIOS*")

    If fileName <> "" Then
        Workbooks.Open (MainPath & fileName)
    End If

I hope you can help me guys, greatings!

Leave a Reply

Your email address will not be published. Required fields are marked *