Open .xls files listed in .txt file and generate report

C

cass calculator

I am trying to figure out how to write the following code:

I would like to have a dialog box open and the user pick the location
of a .txt file. This .txt file will have the full path of numerous
excel files. I would like the script to

1. open every file listed in the .txt file, until they are all open at
the same time
2. save all the files that were opened
3. close all the files that were opened

Then I would like to generate a .txt file in the following location C:
\Model that lists all the files that were opened and saved during the
run of the procedure and the date and time that they were saved.

I haven't been able to figure this out. Can someone help with a
solution?

Thanks,

Joshua
 
N

NOPIK

I am trying to figure out how to write the following code:

I would like to have a dialog box open and the user pick the location
of a .txt file. This .txt file will have the full path of numerous
excel files. I would like the script to

1. open every file listed in the .txt file, until they are all open at
the same time
2. save all the files that were opened
3. close all the files that were opened

Then I would like to generate a .txt file in the following location C:
\Model that lists all the files that were opened and saved during the
run of the procedure and the date and time that they were saved.

I haven't been able to figure this out. Can someone help with a
solution?

Thanks,

Joshua

fName = Application.GetOpenFilename( FileFilter:="Text files
(*.txt),*.txt")
If fName <> False Then
If Dir(fname) <> "" Then 'file exists
Open fname For Input As #1
Do While Not EOF(1)
Line Input #1, workbookpath 'get whole line
Application.Workbooks.Open (workbookpath)
Loop
Close (1)
'Do what you want to do
Open "c:\logfile.txt" For Output As #2
For Each book In Application.Workbooks
book.Save
Print #2, """"; book.Name; """;"; Date; ";"; Time
Next book
Close (2)
End If
End If
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top