try this
Sub check_files_to_open()

    Dim flname As String

    flname = InputBox("Enter file to search")
    Set fso = CreateObject("scripting.filesystemobject")
    Set fld = fso.getfolder("C:\Users\admin\Desktop\New folder")

    For Each fil In fld.Files
        If UCase(Left(fil.Name, InStrRev(fil.Name, ".") - 1)) =
UCase(flname) Then
            Shell "Explorer.exe " & fil.Path, vbNormalFocus
            Exit For
        End If
    Next

End Sub



On Sun, Jul 14, 2013 at 2:19 PM, thameem <thamee...@gmail.com> wrote:

> sorry again not working, its asking to select folder, later file name, if
> i type file name, its actually pdf format but opening in excel format.....
> cant we fix folder path in this program, so there is no need to select
> folder every time
>
>
> On Sun, Jul 14, 2013 at 11:57 AM, ashish koul <koul.ash...@gmail.com>wrote:
>
>> hi try this
>> Sub check_files_to_open()
>>
>>
>> Dim fldpath
>> Dim fld As Object, fil As Object, fso As Object
>> Dim flname As String
>>
>> With Application.FileDialog(msoFileDialogFolderPicker)
>> .Title = "Choose the folder"
>> .Show
>> End With
>>
>> flname = InputBox("Enter file to search")
>>
>> On Error Resume Next
>> fldpath =
>> Application.FileDialog(msoFileDialogFolderPicker).SelectedItems(1) & "\"
>>
>>     If fldpath = False Then
>>         MsgBox "Folder Not Selected"
>>         Exit Sub
>>     End If
>>
>>     Set fso = CreateObject("scripting.filesystemobject")
>>     Set fld = fso.getfolder(fldpath)
>>     For Each fil In fld.Files
>>         If UCase(Left(fil.Name, InStrRev(fil.Name, ".") - 1)) =
>> UCase(flname) Then
>>             Workbooks.Open (fil.Path)
>>             Exit For
>>         End If
>>     Next
>>
>>
>> End Sub
>>
>>
>>
>>
>> On Sun, Jul 14, 2013 at 11:35 AM, thameem <thamee...@gmail.com> wrote:
>>
>>> Sorry, might be I am not explained clearly, example I have file name
>>> "350"
>>>
>>> in that folder i have file names from 1 to 5000, i will type this file
>>> name "350" in one cell, then i will run vba code, so it can open file with
>>> name  "350". please help me
>>>
>>> regards,
>>> thameem
>>>
>>>
>>> On Sun, Jul 14, 2013 at 9:57 AM, ashish koul <koul.ash...@gmail.com>wrote:
>>>
>>>> try this see if it helps
>>>>
>>>> Sub check_files_to_open()
>>>>
>>>>
>>>> Dim fldpath
>>>> Dim fld As Object, fil As Object, fso As Object
>>>>
>>>> With Application.FileDialog(msoFileDialogFolderPicker)
>>>> .Title = "Choose the folder"
>>>> .Show
>>>> End With
>>>>
>>>> On Error Resume Next
>>>> fldpath =
>>>> Application.FileDialog(msoFileDialogFolderPicker).SelectedItems(1) & "\"
>>>>
>>>>     If fldpath = False Then
>>>>         MsgBox "Folder Not Selected"
>>>>         Exit Sub
>>>>     End If
>>>>
>>>>     Set fso = CreateObject("scripting.filesystemobject")
>>>>     Set fld = fso.getfolder(fldpath)
>>>>     For Each fil In fld.Files
>>>>         If Application.WorksheetFunction.CountIf(Range("a:a"),
>>>> fil.Name) >= 1 Then
>>>>             Workbooks.Open (fil.Path)
>>>>             Exit For
>>>>         End If
>>>>     Next
>>>>
>>>>
>>>> End Sub
>>>>
>>>>
>>>>
>>>>
>>>> On Sun, Jul 14, 2013 at 10:51 AM, thameem <thamee...@gmail.com> wrote:
>>>>
>>>>> Dear Experts,
>>>>>
>>>>> I need help, using excel, I need open files from a folder. Example, I
>>>>> have 5000 files is a folder, I have file names in excel, i need to open 
>>>>> any
>>>>> one file using excel. its like that seraching that file name in that
>>>>> folder, if available, then that file should be opened. I have you people
>>>>> understood.
>>>>>
>>>>> regards,
>>>>> Thameem.M
>>>>>
>>>>> --
>>>>> Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be?
>>>>> It’s =TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @
>>>>> https://www.facebook.com/discussexcel
>>>>>
>>>>> FORUM RULES
>>>>>
>>>>> 1) Use concise, accurate thread titles. Poor thread titles, like
>>>>> Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need
>>>>> Advice will not get quick attention or may not be answered.
>>>>> 2) Don't post a question in the thread of another member.
>>>>> 3) Don't post questions regarding breaking or bypassing any security
>>>>> measure.
>>>>> 4) Acknowledge the responses you receive, good or bad.
>>>>> 5) Jobs posting is not allowed.
>>>>> 6) Sharing copyrighted material and their links is not allowed.
>>>>>
>>>>> NOTE : Don't ever post confidential data in a workbook. Forum owners
>>>>> and members are not responsible for any loss.
>>>>> ---
>>>>> You received this message because you are subscribed to the Google
>>>>> Groups "MS EXCEL AND VBA MACROS" group.
>>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>>> an email to excel-macros+unsubscr...@googlegroups.com.
>>>>> To post to this group, send email to excel-macros@googlegroups.com.
>>>>> Visit this group at http://groups.google.com/group/excel-macros.
>>>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> *Regards*
>>>> * *
>>>> *Ashish Koul*
>>>>
>>>>
>>>> *Visit*
>>>> *My Excel Blog <http://www.excelvbamacros.com/>*
>>>> Like Us on 
>>>> Facebook<http://www.facebook.com/pages/Excel-VBA-Codes-Macros/151803898222297>
>>>> Join Us on Facebook <http://www.facebook.com/groups/163491717053198/>
>>>>
>>>>
>>>> P Before printing, think about the environment.
>>>>
>>>>
>>>>
>>>> --
>>>> Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be?
>>>> It’s =TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @
>>>> https://www.facebook.com/discussexcel
>>>>
>>>> FORUM RULES
>>>>
>>>> 1) Use concise, accurate thread titles. Poor thread titles, like Please
>>>> Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice
>>>> will not get quick attention or may not be answered.
>>>> 2) Don't post a question in the thread of another member.
>>>> 3) Don't post questions regarding breaking or bypassing any security
>>>> measure.
>>>> 4) Acknowledge the responses you receive, good or bad.
>>>> 5) Jobs posting is not allowed.
>>>> 6) Sharing copyrighted material and their links is not allowed.
>>>>
>>>> NOTE : Don't ever post confidential data in a workbook. Forum owners
>>>> and members are not responsible for any loss.
>>>> ---
>>>> You received this message because you are subscribed to the Google
>>>> Groups "MS EXCEL AND VBA MACROS" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>> an email to excel-macros+unsubscr...@googlegroups.com.
>>>> To post to this group, send email to excel-macros@googlegroups.com.
>>>> Visit this group at http://groups.google.com/group/excel-macros.
>>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>>
>>>>
>>>>
>>>
>>>  --
>>> Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be?
>>> It’s =TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @
>>> https://www.facebook.com/discussexcel
>>>
>>> FORUM RULES
>>>
>>> 1) Use concise, accurate thread titles. Poor thread titles, like Please
>>> Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice
>>> will not get quick attention or may not be answered.
>>> 2) Don't post a question in the thread of another member.
>>> 3) Don't post questions regarding breaking or bypassing any security
>>> measure.
>>> 4) Acknowledge the responses you receive, good or bad.
>>> 5) Jobs posting is not allowed.
>>> 6) Sharing copyrighted material and their links is not allowed.
>>>
>>> NOTE : Don't ever post confidential data in a workbook. Forum owners and
>>> members are not responsible for any loss.
>>> ---
>>> You received this message because you are subscribed to the Google
>>> Groups "MS EXCEL AND VBA MACROS" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to excel-macros+unsubscr...@googlegroups.com.
>>> To post to this group, send email to excel-macros@googlegroups.com.
>>> Visit this group at http://groups.google.com/group/excel-macros.
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>
>>>
>>>
>>
>>
>>
>> --
>> *Regards*
>> * *
>> *Ashish Koul*
>>
>>
>> *Visit*
>> *My Excel Blog <http://www.excelvbamacros.com/>*
>> Like Us on 
>> Facebook<http://www.facebook.com/pages/Excel-VBA-Codes-Macros/151803898222297>
>> Join Us on Facebook <http://www.facebook.com/groups/163491717053198/>
>>
>>
>> P Before printing, think about the environment.
>>
>>
>>
>> --
>> Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be? It’s
>> =TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @
>> https://www.facebook.com/discussexcel
>>
>> FORUM RULES
>>
>> 1) Use concise, accurate thread titles. Poor thread titles, like Please
>> Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice
>> will not get quick attention or may not be answered.
>> 2) Don't post a question in the thread of another member.
>> 3) Don't post questions regarding breaking or bypassing any security
>> measure.
>> 4) Acknowledge the responses you receive, good or bad.
>> 5) Jobs posting is not allowed.
>> 6) Sharing copyrighted material and their links is not allowed.
>>
>> NOTE : Don't ever post confidential data in a workbook. Forum owners and
>> members are not responsible for any loss.
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "MS EXCEL AND VBA MACROS" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to excel-macros+unsubscr...@googlegroups.com.
>> To post to this group, send email to excel-macros@googlegroups.com.
>> Visit this group at http://groups.google.com/group/excel-macros.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>>
>
>  --
> Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be? It’s
> =TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @
> https://www.facebook.com/discussexcel
>
> FORUM RULES
>
> 1) Use concise, accurate thread titles. Poor thread titles, like Please
> Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice
> will not get quick attention or may not be answered.
> 2) Don't post a question in the thread of another member.
> 3) Don't post questions regarding breaking or bypassing any security
> measure.
> 4) Acknowledge the responses you receive, good or bad.
> 5) Jobs posting is not allowed.
> 6) Sharing copyrighted material and their links is not allowed.
>
> NOTE : Don't ever post confidential data in a workbook. Forum owners and
> members are not responsible for any loss.
> ---
> You received this message because you are subscribed to the Google Groups
> "MS EXCEL AND VBA MACROS" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to excel-macros+unsubscr...@googlegroups.com.
> To post to this group, send email to excel-macros@googlegroups.com.
> Visit this group at http://groups.google.com/group/excel-macros.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>



-- 
*Regards*
* *
*Ashish Koul*


*Visit*
*My Excel Blog <http://www.excelvbamacros.com/>*
Like Us on 
Facebook<http://www.facebook.com/pages/Excel-VBA-Codes-Macros/151803898222297>
Join Us on Facebook <http://www.facebook.com/groups/163491717053198/>


P Before printing, think about the environment.

-- 
Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be? It’s 
=TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @ 
https://www.facebook.com/discussexcel

FORUM RULES

1) Use concise, accurate thread titles. Poor thread titles, like Please Help, 
Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get 
quick attention or may not be answered.
2) Don't post a question in the thread of another member.
3) Don't post questions regarding breaking or bypassing any security measure.
4) Acknowledge the responses you receive, good or bad.
5) Jobs posting is not allowed.
6) Sharing copyrighted material and their links is not allowed.

NOTE  : Don't ever post confidential data in a workbook. Forum owners and 
members are not responsible for any loss.
--- 
You received this message because you are subscribed to the Google Groups "MS 
EXCEL AND VBA MACROS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to excel-macros+unsubscr...@googlegroups.com.
To post to this group, send email to excel-macros@googlegroups.com.
Visit this group at http://groups.google.com/group/excel-macros.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to