Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
i have the following macro (findfile) from this site:
Sub findfile() 'directory to start searching strFolder = "D:\Operations\Human Resources" RowCount = 1 Do Mode = InputBox("What type of search do you want to perform?" & vbCrLf & _ "1: list of folders only" & vbCrLf & _ "2: list of files only" & vbCrLf & _ "3: list of files and folders only") Loop While Mode < 1 Or Mode 3 If Mode = 2 Or Mode = 3 Then Addlinks = MsgBox("Do you want to include Hyperlinks?", vbYesNo, _ Title:=Hyperlinks) Else Hyperlinks = vbNo End If Set fso = CreateObject _ ("Scripting.FileSystemObject") Set folder = _ fso.GetFolder(strFolder) Call GetWorksheetsSubFolder(strFolder + "\", Mode, Addlinks, RowCount) End Sub Sub GetWorksheetsSubFolder(strFolder, Mode, Addlinks, ByRef RowCount) Set fso = CreateObject _ ("Scripting.FileSystemObject") Set folder = _ fso.GetFolder(strFolder) If Mode = 1 Or Mode = 3 Then Range("A" & RowCount) = strFolder RowCount = RowCount + 1 End If If folder.subfolders.Count 0 Then For Each sf In folder.subfolders On Error GoTo 100 Call GetWorksheetsSubFolder(strFolder + sf.Name + "\", Mode, Addlinks, RowCount) 100 Next sf End If 'folder size in bytes On Error GoTo 200 If Mode = 2 Or Mode = 3 Then For Each fl In folder.Files If Addlinks = vbYes Then With ActiveSheet .Hyperlinks.Add Anchor:=.Range("A" & RowCount), Address:=fl.Path, TextToDisplay:=fl.Path End With Else Range("A" & RowCount) = fl End If RowCount = RowCount + 1 Next fl End If 200 On Error GoTo 0 End Sub the macro works as intended, but i do not want the extra options (user enters 1, 2 or 3) and when the list is populated, it shows the full directory path (not wanted) and also has "\" at the end. all i want is the folder name to be populated in the list. because the form that i make will be used on other computers also, i do not want to use an addin, but a code. any help would be appreciated. jat |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
.tmp files filling up my folders | Excel Discussion (Misc queries) | |||
.TMP files are corrupting my folders | Excel Discussion (Misc queries) | |||
Can anyone help me Create Excel list of files in windows folders | Excel Worksheet Functions | |||
links to same files in different folders | Excel Worksheet Functions | |||
Opening Files/Folders | Excel Discussion (Misc queries) |