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: 66
Default run time error 53

I am using a macro to open up unknown files from one folder, put them
in another and change the name. what happenes is when the folder runs
out of files it stops the macro mid point. I need to get past this
error with out a msg box or any stoppage.


Do
ChDir "C:\Documents and Settings\Owner\Desktop\Data log trending
Version 2.0"

Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder("C:\Documents and Settings\Owner\Desktop
\Data log trending Version 2.0\Data log files (by machine)\P124\TXT")
Set tmp = Workbooks.Add
Set myfiles = f.Files
counter = 1
For Each fc In myfiles
tmp.Sheets(1).Cells(counter, 1).Value = fc.Name
tmp.Sheets(1).Cells(counter, 2).Value = fc.datelastmodified
counter = counter + 1
Next
tmp.Sheets(1).Columns("B:B").EntireColumn.AutoFit
tmp.Sheets(1).Range(Selection, Selection.End(xlToRight)).Select
tmp.Sheets(1).Range(Selection, Selection.End(xlDown)).Select
Set sortrange = Selection

For Count = 1 To 1

Set f2 = fso.GetFile("C:\Documents and Settings\Owner\Desktop
\Data log trending Version 2.0\Data log files (by machine)\P124\TXT\"
& tmp.Sheets(1).Cells(Count, 1).Value)
f2.Move ("C:\Documents and Settings\Owner\Desktop\Data log
trending Version 2.0\Data log files (by machine)\P124\Known txt files
\" & tmp.Sheets(1).Cells(Count, 1).Value)
Next Count

tmp.Close False

Set tmp = Nothing

Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder("C:\Documents and Settings\Owner\Desktop
\Data log trending Version 2.0\Data log files (by machine)\P124\DAT")
Set tmp = Workbooks.Add
Set myfiles = f.Files
counter = 1
For Each fc In myfiles
tmp.Sheets(1).Cells(counter, 1).Value = fc.Name
tmp.Sheets(1).Cells(counter, 2).Value = fc.datelastmodified
counter = counter + 1
Next
tmp.Sheets(1).Columns("B:B").EntireColumn.AutoFit
tmp.Sheets(1).Range(Selection, Selection.End(xlToRight)).Select
tmp.Sheets(1).Range(Selection, Selection.End(xlDown)).Select
Set sortrange = Selection

For Count = 1 To 1
Set f2 = fso.GetFile("C:\Documents and Settings\Owner\Desktop
\Data log trending Version 2.0\Data log files (by machine)\P124\DAT\"
& tmp.Sheets(1).Cells(Count, 1).Value)
On Error Resume Next
f2.Move ("C:\Documents and Settings\Owner\Desktop\Data log
trending Version 2.0\Data log files (by machine)\P124\Known dat files
\" & tmp.Sheets(1).Cells(Count, 1).Value)
Next Count

tmp.Close False

Set tmp = Nothing

s1 = "C:\Documents and Settings\Owner\Desktop\Data log trending
Version 2.0\Data log files (by machine)\P124\Known txt files\"
sName = Dir(s1 & "*.*")
i = 0
Do While sName < ""
i = i + 1
Name s1 & sName As s1 & i & ".txt"
sName = Dir()
Loop
s1 = "C:\Documents and Settings\Owner\Desktop\Data log trending
Version 2.0\Data log files (by machine)\P124\Known dat files\"
sName = Dir(s1 & "*.*")
i = 0
Do While sName < ""
i = i + 1
Name s1 & sName As s1 & i & ".dat"
sName = Dir()
Loop



Please help
 
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
run time error 1004 general odbc error excel 2003 vba Mentos Excel Programming 5 January 24th 11 02:56 PM
Visual Basic Error Run Time Error, Type Mismatch Meg Partridge Excel Discussion (Misc queries) 12 September 10th 08 06:10 PM
Error handling error # 1004 Run-time error [email protected] Excel Programming 3 May 20th 08 02:23 PM
Conditional Formatting - Run Time Error '13' Type Mismatch Error ksp Excel Programming 0 July 11th 06 07:06 AM
run-time error '1004': Application-defined or object-deifined error [email protected] Excel Programming 5 August 10th 05 09:39 PM


All times are GMT +1. The time now is 09:51 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"