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: 18
Default Open and Save Files in Directory

I'd like to be able to select a directory and for each .xls file found
in the directory 1) open the .xls file 2) write the name and date
saved in another workbook (in this case "workbook report.xls") and 3)
save and close the workbook.

I have the shell of the loop but I'm missing the pieces where I've
written comments. A solution for this would be greatly appreciated!
Thanks.


Sub OpenAndSaveFiles()
Dim wkbk As Workbook
Dim StrWkbk As String
' open a form that allows the user to select a directory i.e. C:\temp

Workbooks("Workbook Report.xls").Worksheets("Sheet1").Range
("A1").Select
With Application.FileSearch
.NewSearch
' look in the directory selected in the form above i.e. C:\temp
.LookIn = "C:\Temp"
.SearchSubFolders = False
.Filename = ".xls"
.FileType = msoFileTypeExcelWorkbooks

If .Execute() 0 Then
For i = 1 To .FoundFiles.Count
' save the filename and date saved of each found file in workbook
report.xls
wkbk.Close SaveChanges:=False
Next i
Else
MsgBox "There were no files found."
End If
End With
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
open all files in directory davethewelder Excel Discussion (Misc queries) 2 August 26th 08 02:01 PM
Open files in the same directory houghi Excel Discussion (Misc queries) 2 May 21st 07 03:56 PM
open in old directory save in new directory tim64[_2_] Excel Programming 0 June 15th 05 07:48 PM
Open files in directory V. Roe Excel Programming 2 November 4th 03 07:45 PM
Open all files in a directory Tom Waters[_2_] Excel Programming 1 September 3rd 03 12:59 PM


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