Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default Help with file search / Dir()

I need some help with the following code:

'
Dim myCount As Long
'
'
If (Lbx_file_names.Value < "") Then
'
Adobe_Filename_Pick = Lbx_file_names.Value
'
End If
'
Lbx_file_names.Clear
MyFolder = "X:\Omar\Finished_Flanges\"
'
'myFile = Dir(myFolder & "*.pdf")
MyFile = Dir(MyFolder & Flange_sname & ".pdf")
'
myCount = 0
If MyFile < "" Then
Do
myCount = myCount + 1
Lbx_file_names.AddItem MyFile
'
MyFile = Dir()
Loop While MyFile < ""
End If
'

I want to search the directory X:\Omar\Finished_Flanges\ and all of its
subdirectories. I think i can do it with filesearch but am not sure. Please
offer some suggestions.

Thanks,
Omar
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default Help with file search / Dir()

Hello Omar,

Not exactly sure what you are attempting to do but perhaps the following
code example that I think originated from Jacob Skaria will help to point you
in the right direction. I tried to find the post but failed so here is a copy
of it.

Sub findfile()
Dim Addlinks
'Directory to start searching
strFolder = CurDir

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)

Columns("A:A").Clear 'Clear All required to clear hyperlinks from
previous run of code
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

--
Regards,

OssieMac


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
file search or search files Richad Excel Discussion (Misc queries) 0 October 22nd 09 07:56 PM
File Search Sgwapt Excel Programming 2 July 3rd 08 02:43 AM
Search a FAQ file Jane Excel Worksheet Functions 1 October 18th 06 09:07 PM
Turning a text file name into a search and linking the file as a hyperlink AlistairM Excel Discussion (Misc queries) 1 January 26th 06 04:55 AM
Macro to search from one file & place on another file. Luong[_2_] Excel Programming 0 May 6th 04 04:53 PM


All times are GMT +1. The time now is 07:53 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"