Search for a file on using wild cards VBA

E35123

New Member
Joined
Nov 6, 2018
Messages
1
I am attempting to search for a file using wild cards but am having trouble making it work.

I get the Run-time error '52'
Bad File name or number

Here is my code

Sub OpenFiles()

Dim MyFolder As String
Dim MyFile As String

MyFolder = "https://xyz.zyz.com/sites/............/Labor%20Tool%20Data" 'EXACT folder name containing the files. Change to suit, but don't forget the trailing backslash '\'
Debug.Print MyFolder
MyFile = Dir(MyFolder & "/*066*.xlsm")

Do Until MyFile = ""
Workbooks.Open filename:=MyFolder & "" & MyFile
MyFile = Dir
Loop

End Sub


I am using the full path name to the folder.

I have read in various post that this is possible. Why do i always get "Bad File name or number"?

IS this possible to search for a file with in a folder using wild cards?

E35123
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest

Forum statistics

Threads
1,215,517
Messages
6,125,288
Members
449,218
Latest member
Excel Master

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