When I do a file-open or file-save my system hangs up for several seconds - it comes to a stop at the drop-down arrow & I have to click on it again and still wait. It seems this problem only happens after I use an Excel macro that an Expert helped me create using filesystemobject. Some of that macro is posted below. It appears to me to be releasing the filesystemobject - but I'm no expert & could easily be wrong. After the macro is completed could there be anything left in memory that causes Excel to do this hesitation? When the hesitation happens with Excel & I try to use Word the same hesitation occurs. Windows Explorer works OK all of the time. No one else at work has complained about this problem so I figue it's something I am doing/using that they aren't.
Dim f
Dim fl
Dim ofl
Dim Path As String
Dim fso
Set fso = CreateObject("scripting.fi
lesystemob
ject")
Path = "C:\My Documents\Files\"
For Each f In fso.GetFolder(Path).Files
fName = f.Name
'This macro only looks at the Detailed General Ledger text files.
If UCase(fName) Like "FMTLPFK*.TXT" Then
'make a copy of the original file in "Original" subdirectory & make a work copy to filter
fso.CopyFile Path & fName, Path & "Original\" & fName
f.Name = fName & "v2"
vCT = 0
Set ofl = f.OpenAsTextStream
Set fl = fso.CreateTextFile(Path & fName)
Do Until ofl.AtEndOfStream
TempStr = ofl.ReadLine
vCT = vCT + 1
If vCT < 10 Then
fl.WriteLine TempStr
Else
LOOP THROUGH & DO A BUNCH OF STUFF HERE
'Save & close the workbook
ActiveWorkbook.Save
ActiveWindow.Close
fso.DeleteFile Path & fName
'OPEN THE NEXT FILE IN THE DIRECTORY UNTIL ALL ARE PROCESSED
End If
End If
Next
MsgBox "The Processed EXCEL files were saved in " & Path & _
"Processed\" & " and Original TEXT files were moved to " & Path & "Original\"
Set f = Nothing
Set fl = Nothing
Set fso = Nothing
End Sub
Start Free Trial