Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 37
Default automated file loading and saving

Hi Maurice,

The code below should do what your after:

Sub FindDataFiles()
StartTime = Now
Application.ScreenUpdating = False
Application.DisplayAlerts = False
With Application.FileSearch
.NewSearch
.LookIn = "C:\Data"
.SearchSubFolders = True
.Filename = "*.squ"
.MatchTextExactly = True
.FileType = msoFileTypeAllFiles
If .Execute() 0 Then
MsgBox "There were " & .FoundFiles.Count & _
" file(s) found."
For i = 1 To .FoundFiles.Count
Application.DisplayAlerts = False
Opentxt = .FoundFiles(i)
Workbooks.OpenText Filename:=Opentxt, _
Origin:=xlWindows, StartRow:=1, DataType:=xlDelimited,
TextQualifier:= _
xlNone, ConsecutiveDelimiter:=False, Tab:=False,
Semicolon:=False, Comma _
:=False, Space:=False, Other:=False, FieldInfo:=Array(1, 1), _
TrailingMinusNumbers:=True
ActiveWorkbook.SaveAs Opentxt, xlNormal
Next i
Timemsg = "The time taken was " & Round((Now - StartTime) * 24 * 60
* 60, 2)
MsgBox "All files that were found have now been saved as excel
files." _
& vbCr & Timemsg & " Second(s)"
End Sub

The timer that you wanted I presumed was to calculate how long the
macro took. If this is wrong then you will need to change the Msgbox at
the end of the code. The workbook open line opens the text file but
doesn't delimit the columns at all, this was also a guess.

Any problems then give me a shout.

James

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
Excel 2007 - error saving file & error loading dll TinaF Excel Discussion (Misc queries) 0 July 1st 09 01:49 PM
Excel 2007 one network file running (loading and saving) slow Polly Welch Excel Discussion (Misc queries) 0 July 20th 07 11:44 PM
Automated Saving of File SU Excel Programming 6 November 21st 05 08:12 PM
Automated saving - Please Help & Advice SU Excel Programming 2 March 1st 05 12:28 PM
Excessive time loading/saving file Emile Zac Excel Programming 2 September 18th 04 10:46 PM


All times are GMT +1. The time now is 09:17 AM.

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"