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


I don't know if anyone could help with this. The idea is fairly simple.
At present I have a macro that searches for a file. Each file name is
47 char long and is found using

Set fs = Application.FileSearch
With fs
LookIn = "G:\PUB"
SearchSubFolders = False
Filename =
Out_TkbAwMegVLHRkMfximTWZRvqohpTQOjKNqXN.finish
etc...

Is there a way of of searching using a 'like' statement eg,

filename like Out_TkbAw ??


--
Jimbo1
------------------------------------------------------------------------
Jimbo1's Profile: http://www.excelforum.com/member.php...o&userid=30637
View this thread: http://www.excelforum.com/showthread...hreadid=527100

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 75
Default Help with filename search


try this code - maybe it would be helpful...

Sub ff()

Dim fs As Object
Dim temp_name As String
Dim i As Long

temp_name = "Out_TkbAw"


Set fs = Application.FileSearch
With fs
..NewSearch
..LookIn = G:\PUB"
..SearchSubFolders = False
..MatchTextExactly = False
..Filename = temp_name
..Execute

For i = 1 To .FoundFiles.Count
MsgBox .FoundFiles(i)
Next i


End With


End Sub


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 75
Default Help with filename search


'maybe we could add an additional loop:

if .FoundFiles.Count 0 then

For i = 1 To .FoundFiles.Count
MsgBox .FoundFiles(i)
Next i

else

MsgBox "No files !"

end if



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Help with filename search


thank for reply. Haven't had time to test it yet but it looks as though
I can use it. cheers


--
Jimbo1
------------------------------------------------------------------------
Jimbo1's Profile: http://www.excelforum.com/member.php...o&userid=30637
View this thread: http://www.excelforum.com/showthread...hreadid=527100

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 246
Default Help with filename search

Snake, how do I take your code and go one step further. That is, if
there are found files, I would like to open each file, copy sheet(1) of
each WB to a summary WB, close the found file without saving and print
the summary WB. TIA

Greg



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Help with filename search


try to use smtg like that... the code is not optimized i suppose - I
didnt check it coz it's late :-)

Sub ff()

Dim fs As Object
Dim temp_name, folder_name, base_file, temp_file As String
Dim i, j As Long

temp_name = ".xls"
folder_name = "C:\"
base_file = Application.ActiveWorkbook.Name



Set fs = Application.FileSearch
With fs
..NewSearch
..LookIn = folder_name
..SearchSubFolders = False
..MatchTextExactly = False
..Filename = temp_name
..Execute

If .FoundFiles.Count 0 Then

For i = 1 To .FoundFiles.Count

Workbooks.Open Filename:=.FoundFiles(i)
temp_file = Application.ActiveWorkbook.Name

Sheets(1).Copy
After:=Workbooks(base_file).Sheets(Application.Wor kbooks(base_file).Sheets.C
ount)
Workbooks(temp_file).Close SaveChanges:=False

Next i


For j = 1 To Workbooks(base_file).Sheets.Count

Sheets(j).Select
ActiveWindow.SelectedSheets.PrintOut Copies:=1

Next j

Else

MsgBox "No files to perform!"

End If



End With


End Sub


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
set filename to <filename-date on open bob engler Excel Worksheet Functions 2 July 13th 06 05:11 AM
filename search and extract into a cell M John Excel Discussion (Misc queries) 5 April 28th 06 10:11 PM
Search filename containing words Bob Phillips[_6_] Excel Programming 0 December 22nd 04 09:44 AM
Saving filename same as import filename Matt Excel Programming 4 February 24th 04 03:01 PM
Filename search using Office 97 with Windows 2000 Dave[_30_] Excel Programming 3 September 15th 03 04:57 PM


All times are GMT +1. The time now is 06:40 AM.

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"