Wrox Programmer Forums
|
VB How-To Ask your "How do I do this with VB?" questions in this forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 18th, 2005, 01:14 PM
ct ct is offline
Authorized User
 
Join Date: Aug 2005
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
Default search

hi everyone..
can somebody give me some code to perform file search. i use vb editor in ms excel.
i had try this..

with
.filesearch = "c:\my document\wan"
.filetype = ......".xls : .pdf"
.filename = textbox.text
execute
end with

i want to search for .xls and .pdf file which i locate them in a folder namely "wan".
i have a textbox, user may enter the path name of the file.. when they click search button, it will directly check file availability in "wan" folder.

when i run above code, .filename, . filesearch, .filetype appear to be error. may i know why? any suggestion? thank you very much for your time..

 
Old October 18th, 2005, 08:14 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 627
Thanks: 0
Thanked 0 Times in 0 Posts
Default

the "with" statement needs the object you want to work with

Marco
 
Old October 20th, 2005, 05:43 PM
ct ct is offline
Authorized User
 
Join Date: Aug 2005
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thanks for the reply..

With Application.FileSearch
    .LookIn = "C:\My Documents"
    .SearchSubFolders = True
    .Filename = Code.Text
    .MatchTextExactly = True
    .FileType = msoFileTypeExcelWorkbooks

    If .Execute() > 0 Then
        MsgBox "There were " & .FoundFiles.Count & _
            " file(s) found."
        For i = 1 To .FoundFiles.Count
            MsgBox .FoundFiles(i)
            fileToOpen = Application _
            .GetOpenFilename = FileName
                If fileToOpen <> False Then
                    MsgBox "Open " & fileToOpen
                End If

        Next i
    Else
        MsgBox "There were no files found."
    End If
End With

i had try this one.. i can displays the standard Open dialog box and gets a file name from the user but i cannot open any files.
how to directly open the file (excel workbook)? can i make this possible? or any other suggesstion. i need respon from anybody, asap..thanks a lot..








Similar Threads
Thread Thread Starter Forum Replies Last Post
Search button doesn't search Access DB cbones Visual Studio 2008 1 October 27th, 2008 07:36 PM
New text search doesn't preselect search string planoie Visual Studio 2005 0 July 23rd, 2007 06:47 AM
File Search / Indexing Search with .net 2.0 maulik77 ASP.NET 1.0 and 1.1 Basics 2 March 15th, 2007 12:45 AM
Search Engine for Full-text Search Kala ASP.NET 1.0 and 1.1 Professional 2 August 29th, 2004 02:16 AM
Search engine that search through local drive! wenzation Classic ASP Basics 0 August 26th, 2003 09:15 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.