LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #17   Report Post  
Posted to microsoft.public.excel.programming
rjr rjr is offline
external usenet poster
 
Posts: 50
Default Code looping through files new line

Hello again,
Otto and I have talking this morning and here are some clarifications about
what we have discovered.
first the source of my files are from a mainframe which saves as a csv file
and I open it in MS Excel. Once opened I save it as an Excel .xls file and
download it to my computer. All the files that we've been dealing with are
of this nature.

Otto has asked me to document the downloading process for these files and
post them here in case we have a issue with the excel files. I will repost
after this evening to see if I can document the process and recreate the
issues. If I cant' recreate then it will have to be in the initial files
that were saved in excel. If I do recreate the problem I'll return and ask
for more advice. I tryly appreciate all of you for sticking by and trying to
help me out.
Thanks

Bob Reynolds


Next Otto asked me to clean out the folder and then create new .xls files
(blank) and save them in the directory. The names were Book (1) (2) etc... I
have six of those files placed in the folder and we discovered there was no
problems with the opening and closing of the files. Otto gave me Debra's
maco from her werbsite and all seems well at this time.
"rjr" wrote in message
.. .
Started new here, the others are getting pretty deep.

OK, Have tried using this with several different issues this morning.
Here's the outcome.
I used the F8 to step through it and see what was happening and also just
ran the code and let her rip.
I got several messages regarding the files weren't processed, using the
full code. and I got a couple there were processed.
then using the test code Tom wanted me to last night that worked, I got
the first two didn't work, but the rest did as they were supposed to,
opened the file and made the specific changes and closed the fiel.
The first two files weren't opening as they should and I then opened them
both manually and they opened and looked fine, and then I closed them out.
They are the first two in alphabetical order.
I then changed the order and was able to get two of the 22 to open. The
others seemed to hang on
et wb = Workbooks.Open(fl.Path)
and then went to the error. I've got to go to work today and will try new
files, but it would seem to me that if one or more works properly then
something in the file would be the problem. Unfortunately all files were
saved the same way and all were exported to excel in csv format, the files
were opened and then saved as in xls format.

Is there a need to put a slight pause into the code that when it attempts
to start opening the file it would pause and make sure the file had enough
time to open, or am I asking a stupid thing???

Thanks again
Bob Reynolds
Sub AllFiles()
Dim sFol As String
Dim fso As Object, fl As Object
Dim fld As Object
Dim wb As Workbook
sFol = "C:\temp"
Set fso = CreateObject("Scripting.FileSystemObject")
Set fld = fso.GetFolder(sFol)
For Each fl In fld.Files
if lcase(fl.Path) < lcase(thisworkbook.Fullname) then
If fl.Name Like "*.xls" Then
On Error Resume Next
Set wb = Workbooks.Open(fl.Path)
if err.number = 0 then
MsgBox wb.FullName
wb.Close
else
msgbox "Not processed: " & fl.Path
err.Clear
end if
On Error goto 0
End If
End if
Next
End Sub





 
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
Looping thru Files In FolderSub Jim May Excel Programming 4 August 2nd 06 11:49 PM
Looping through excel files to add to a new workbook Geoff Excel Programming 8 April 29th 06 11:54 AM
Looping through files in a folder prepotency[_12_] Excel Programming 1 July 13th 05 04:23 PM
Looping thru files extracting data gtslabs[_2_] Excel Programming 3 June 3rd 05 04:22 PM
Looping thru files Tom Excel Programming 4 January 9th 04 05:05 PM


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