Rebecca Shabad
asked on
how do i open a file if i only know part of the file name
How to visible a filename*esy pattern related all files simultaneously from the directory. Please find the below code and suggest.
Const SOME_PATH As String = "C:\Anderson\"
Dim file As String
file = Dir(SOME_PATH & "filename*esy" & ".")
If (Len(file) > 0) Then
MsgBox ("Found")
Else
MsgBox ("Not Found")
End If
End Sub
SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
It's possible to visible all partial named(filenames*esy) xml files via notepad?
Why not just do this at a DOS command prompt?
Open the Command Prompt, switch to the folder to report on via the CD command, and then run:
dir /b "filenames*esy.xml"
If you want to save the list of files to a file add:
dir /b "filenames*esy.xml">list.t xt
then if you want open the list.txt file in Notepad for viewing.
»bp
Open the Command Prompt, switch to the folder to report on via the CD command, and then run:
dir /b "filenames*esy.xml"
If you want to save the list of files to a file add:
dir /b "filenames*esy.xml">list.t
then if you want open the list.txt file in Notepad for viewing.
»bp
ASKER
Yes I know that method through Command Prompt method. So it's not possible to code in word vba?
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
The above code is not working its only showing No files found and print C:\log: in word
The two constants need to be set properly to specify a location where matching files actually exist. There must be a backslash at the end of the BASE_FOLDER constant.
Const BASE_FOLDER As String = "C:\Anderson\"
Const FILE_FILTER As String = "filename*esy.xml"
»bp
Const BASE_FOLDER As String = "C:\Anderson\"
Const FILE_FILTER As String = "filename*esy.xml"
»bp
ASKER
Multiple Files in Directory:
filename1292_endeesy
filename129_endeesy
filename_Aasdeesy
filename-sasks_endeesy