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

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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