Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Open .xls files listed in .txt file and generate report
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Open .xls files listed in .txt file and generate report
On Jun 29, 9:41 pm, cass calculator wrote:
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
"Open File" listed in reverse-alphabetical order. | Excel Discussion (Misc queries) | |||
how do I use a file list to recall data from listed files? | Excel Worksheet Functions | |||
How to exctract files listed in an Excel-file from a folder? | Excel Discussion (Misc queries) | |||
Generate Report | Excel Worksheet Functions | |||
file open via IE hyperlink causes already open files to shrink and tile | Setting up and Configuration of Excel |