is it giving any errors

try this code . i haven't tried it on server. always on my local desktop


Sub withsubfolder()
Dim fldpth As String
fldpth = "ftdpth = \\codebase1\docs\pdf\"
 Dim r As Long
        ListFilesInFolder fldpth, True
      End Sub

Sub ListFilesInFolder(SourceFolderName As String, IncludeSubfolders As
Boolean)

Dim fso As Scripting.FileSystemObject
Dim SourceFolder As Scripting.Folder, SubFolder As Scripting.Folder
Dim FileItem As Scripting.File
Dim r As Long
    Set fso = New Scripting.FileSystemObject
    Set SourceFolder = fso.GetFolder(SourceFolderName)

    For Each FileItem In SourceFolder.Files

      If Right(FileItem.Path, 4) = ".pdf" Then
        r = Range("a65356").End(xlUp).Row + 1

        Cells(r, 1).Select
        ActiveSheet.Hyperlinks.Add Anchor:=Selection,
Address:=FileItem.Path, TextToDisplay:=Left(FileItem.Name,
InStrRev(FileItem.Name, ".") - 1)
End If

    Next FileItem
    If IncludeSubfolders Then
        For Each SubFolder In SourceFolder.SubFolders
            ListFilesInFolder SubFolder.Path, True
        Next SubFolder
    End If
    Set FileItem = Nothing
    Set SourceFolder = Nothing
    Set fso = Nothing
   End Sub




On Fri, Mar 25, 2011 at 10:57 PM, Dave <davidstev...@gmail.com> wrote:

> Ok , I added Microsoft Scripting Runtime in the refrence, its #5 in the
> Priority list , but the macro is still not  picking up sub-directories.
>
> thanks again
>
>
>



-- 
*Regards*
* *
*Ashish Koul*
*akoul*.*blogspot*.com <http://akoul.blogspot.com/>
*akoul*.wordpress.com <http://akoul.wordpress.com/>
My Linkedin Profile <http://in.linkedin.com/pub/ashish-koul/10/400/830>


P Before printing, think about the environment.

-- 
----------------------------------------------------------------------------------
Some important links for excel users:
1. Follow us on TWITTER for tips tricks and links : 
http://twitter.com/exceldailytip
2. Join our LinkedIN group @ http://www.linkedin.com/groups?gid=1871310
3. Excel tutorials at http://www.excel-macros.blogspot.com
4. Learn VBA Macros at http://www.quickvba.blogspot.com
5. Excel Tips and Tricks at http://exceldailytip.blogspot.com
 
To post to this group, send email to excel-macros@googlegroups.com

<><><><><><><><><><><><><><><><><><><><><><>
Like our page on facebook , Just follow below link
http://www.facebook.com/discussexcel

Reply via email to