0

I have the following short vba code to open a file which name begins with the string "QryCECARFSECTORIAL". Neverthless, since the file name is not composed only by that string and it varies every day, I've used the metacharacter "*" as following:

Sub prueba2()


Dim WB As Workbook

Set WB = Workbooks.Open("V:\evfilesce9i9\RF Sectorial 2018-05\QryCECARFSECTORIAL*")

When I use it, the code doesn't find the file in question (I've already checked and the file indeed exists)

¿Am I using metacharacter "*" in the right way?

Mauro
  • 477
  • 1
  • 9
  • 22
  • You first need to locate the file path using the `*` wildcard and then pass the full path to the method. – Kostas K. Jun 18 '18 at 13:00
  • You really do not need these - `\\\` – Vityata Jun 18 '18 at 13:00
  • @Vityata, it was a typo, thanks. – Mauro Jun 18 '18 at 14:56
  • @KostasK. I tried dimming ``\QryCECASECTORIAL`` as a string called namefile and ``V:\evfilesce9i9\RF Sectorial 2018-05`` as a string called path, and appliyng the open method as: ``Set WB = Workbooks.Open(path & namefile)``, but it doesn't work yet again with the same error. – Mauro Jun 18 '18 at 15:04

0 Answers0