Results 1 to 8 of 8

Thread: Extended function available for Application.FileDialog(msoFileDialogFolderPicker)?

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2010
    Posts
    13

    Extended function available for Application.FileDialog(msoFileDialogFolderPicker)?

    Hello everybody,

    Is anybody aware of the following; is it possible to use the above mentioned folder picker function which will also includes all sub folders of the selected directory.

    The issue is I would like to scan a special folder including all sub folders regarding doc and docx files which are stored in all those directories.

    Among other things I tried to use the application.filesearch function as well - but unfortunately without any success up to now.

    Can anybody advise?
    Cheers
    Joey

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Extended function available for Application.FileDialog(msoFileDialogFolderPicker)

    I'm guessing you are using some form of VBA (Excel, Access, etc) rather than VB6, so I'm moving your thread to Office Development.

  3. #3

    Thread Starter
    New Member
    Join Date
    May 2010
    Posts
    13

    Re: Extended function available for Application.FileDialog(msoFileDialogFolderPicker)

    Quote Originally Posted by Hack View Post
    I'm guessing you are using some form of VBA (Excel, Access, etc) rather than VB6, so I'm moving your thread to Office Development.
    You are right - Thanks and sorry!

  4. #4
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Extended function available for Application.FileDialog(msoFileDialogFolderPicker)

    see examples from the help files
    vb Code:
    1. Set fs = Application.FileSearch
    2. With fs
    3.     .LookIn = "C:\test"
    4.     .SearchSubFolders = True
    5.     .Filename = ".doc*"
    6.     .MatchTextExactly = True
    7.     .FileType = msoFileTypeAllFiles
    8.     .Execute
    9. End With
    all files with extention starting doc will be found in test and all subfolders, loop through fs.foundfiles
    For I = 1 To fs.FoundFiles.Count
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  5. #5

    Thread Starter
    New Member
    Join Date
    May 2010
    Posts
    13

    Re: Extended function available for Application.FileDialog(msoFileDialogFolderPicker)

    Hi Pete,

    Thanks for your reply. Do you see any chance to use the Application.FileDialog(msoFileDialogFolderPicker) function with a '.searchSUBfolder function?'

    cheers
    Joey

  6. #6
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Extended function available for Application.FileDialog(msoFileDialogFolderPicker)

    i don't see it as application.filedialog is not available in my version of office,
    msoFileDialogFolderPicker is not a valid constant for me

    filesearch returns all files from subfolders if set to do so, if you want a folder picker i would use shbrowseforfolder, which can display files, but only folders can be selected
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  7. #7

    Thread Starter
    New Member
    Join Date
    May 2010
    Posts
    13

    Re: Extended function available for Application.FileDialog(msoFileDialogFolderPicker)

    Quote Originally Posted by westconn1 View Post
    i don't see it as application.filedialog is not available in my version of office,
    msoFileDialogFolderPicker is not a valid constant for me

    filesearch returns all files from subfolders if set to do so, if you want a folder picker i would use shbrowseforfolder, which can display files, but only folders can be selected
    Hi Pete,

    I would like to use this code.
    Code:
    Dim d As Document, t As Table, b As Border
    Dim docnames As String, fnd As Boolean, maypath As String, fname As String
     
    mypath = "c:\test\"
    fname = Dir(mypath & "*.doc?")
    Do While Len(fname) > 0
        Set d = Documents.Open(mypath & fname)
        fnd = False
        For Each t In d.Tables
            For Each b In t.Borders
                If b.LineStyle = wdLineStyleDot Then
                    docnames = docnames & d.Name & vbNewLine: fnd = True: Exit For
                End If
            Next
            If fnd Then Exit For
        Next
        fname = Dir
    Loop
    Regarding the mypath VAR I´m currently using the Application.FileDialog folder picker function to get the folder path which should be scanned. Now I´m really struggling related to the sub folders, I just thought I can do something like that...

    Code:
    Public Sub Search(Path As String) 
        Dim fld As Folder, Subfld As Folder, fleFile As File 
        
        Set fld = fso.GetFolder(Path)
        For Each Subfld In fld.SubFolders 
            Search Subfld.Path 
        Next 
        Label1.Caption = "Search in" & fld.Path
        For Each fleFile In fld.Files 
            If fso.GetExtensionName(fleFile.Name) = "doc" Then 
               Chkdotted_table
            End If 
        Next 
        DoEvents 
    End Sub
    but it doesn´t work. Do you have any hint for me how to check every doc file (in every folder) if these doc files include dotted tables?

    Thanks for your support

  8. #8
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Extended function available for Application.FileDialog(msoFileDialogFolderPicker)

    search in this or vb6 forum for recursive dir or recursive fso, there will be several examples
    http://www.vbforums.com/showthread.p...ight=recursive

    application.filesearch will do it all for you, without the recursive function
    Last edited by westconn1; Oct 5th, 2010 at 03:27 PM.
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width