LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 157
Default Customising Application.Filesearch to process textpad kind of files

Hi,

I have a folder named "C:\Documents and
Settings\abc\Desktop\Automate\Dev\From Client\Raw Data"

Within the Raw Data folder I have subfolders named "Week 1", "Week 2", "Week
3" etc.

Within a particular week's folder (let's say "Week 1"), I have some LST
files (a notepad or textpad kind of file). I want to programmatically open
these text kind of files and save them as XLS files in a different folder .

To convert a single file I have the following macro.

Sub RenamingLSTasXLS()

Workbooks.OpenText Filename:= _
"C:\Documents and Settings\abc\Desktop\Automate\Dev\From Client\Raw
Data\week 1\dev11112.lst", Origin:=437, StartRow _
:=1, DataType:=xlDelimited, TextQualifier:=xlDoubleQuote, _
ConsecutiveDelimiter:=False, Tab:=False, Semicolon:=False,
Comma:=False _
, Space:=False, Other:=False, FieldInfo:=Array(1, 1), _
TrailingMinusNumbers:=True

Application.DisplayAlerts = False

ActiveWorkbook.SaveAs Filename:= _
"C:\Documents and Settings\abc\Desktop\Automate\Dev\Working
Files\Renaming\dev11112.xls", FileFormat:=xlNormal, _
Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, _
CreateBackup:=False

ActiveWorkbook.Close
Application.DisplayAlerts = True
End Sub

Now, since I automatically want to do the above for all the LST files within
the Raw Data folder I used the following "Application.filesearch" method
(somebody in the NG helped me with this feature when I wanted to open XLS
files programmatically.)

Sub OpenLSTfilesInLocation()

Application.ScreenUpdating = False
Dim i As Integer
With Application.FileSearch
.NewSearch
.LookIn = "C:\Documents and Settings\abc\Desktop\Automate\Dev\From
Client\Raw Data"
.SearchSubFolders = True
.FileType = msoFileTypeExcelWorkbooks
.Execute
For i = 1 To .FoundFiles.Count
Call RenamingLSTasXLS
Next i
End With
Application.ScreenUpdating = True

End Sub

The problem with the Sub OpenLSTfilesInLocation() is ..

a) I want to open LST files only and not Excel files, so in the above code
what should I substitute .FileType = msoFileTypeExcelWorkbooks with so that
I get the count of LST files. I searched help for filetypes but couldnt get
any help..

b) How may I pass the name of the LST files as an argument to the Sub
RenamingLSTasXLS().

--
Thanks a lot,
Hari
India


 
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
Application.FileSearch Cleberton(Brazilian) Excel Discussion (Misc queries) 2 October 26th 09 01:21 PM
How to Kill Excel application process HoGo Excel Programming 2 December 13th 04 10:53 AM
Application.Filesearch yields incorrect results?? Ed[_23_] Excel Programming 2 August 24th 04 08:59 PM
VBA Application.FileSearch Roger Frye Excel Programming 0 March 5th 04 04:07 AM
Application Process-Shell Command GarethG[_10_] Excel Programming 2 October 29th 03 01:35 PM


All times are GMT +1. The time now is 04:26 PM.

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

About Us

"It's about Microsoft Excel"