Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
opening each file in a folder
I'm having trouble getting started on a macro. I want to go to a specific
folder and open each file with an ".XLS" extension in that folder. Can that be done? If so, I would appreciate any help in getting started with this code. Thanks for the help. -- JT |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
opening each file in a folder
Look in Excel VBA help at the DIR function. The sample code provided there
should get you started. -- Regards, Tom Ogilvy "JT" wrote in message ... I'm having trouble getting started on a macro. I want to go to a specific folder and open each file with an ".XLS" extension in that folder. Can that be done? If so, I would appreciate any help in getting started with this code. Thanks for the help. -- JT |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
opening each file in a folder
See the examples on my site
http://www.rondebruin.nl/copy3.htm Or http://www.rondebruin.nl/copy4.htm -- Regards Ron de Bruin http://www.rondebruin.nl "JT" wrote in message ... I'm having trouble getting started on a macro. I want to go to a specific folder and open each file with an ".XLS" extension in that folder. Can that be done? If so, I would appreciate any help in getting started with this code. Thanks for the help. -- JT |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
opening each file in a folder
Here's an earlier post of my which seems similar (the same). Post back if
you need more help ------------------------------*-------------------------- This code uses the FileSystemObject to loop through all files in a directory, seek out Excel worksheets, and opens them, copies A1:A3 on the first sheet to column A, then moves on. You will need to adapt to whatever ranges you want to use. Sub OpenFiles() Dim objFSO As Object Dim objFolder As Object Dim objSubfolder As Object Dim objFile As Object Dim iRow As Long iRow = 1 Set objFSO = CreateObject("Scripting.FileSystemObject") Set objFolder = objFSO.GetFolder("c:\myTest") For Each objFile In objFolder.Files If objFile.Type = "Microsoft Excel Worksheet" Then Workbooks.Open Filename:=objFolder.Path & "\" & objFile.Name ActiveWorkbook.Worksheets(1).Range("A1:A3").Copy _ Destination:=ThisWorkbook.Worksheets(1).Cells(iRow , 1) ActiveWorkbook.Close iRow = iRow + 3 End If Next End Sub -- HTH RP (remove nothere from the email address if mailing direct) "JT" wrote in message ... I'm having trouble getting started on a macro. I want to go to a specific folder and open each file with an ".XLS" extension in that folder. Can that be done? If so, I would appreciate any help in getting started with this code. Thanks for the help. -- JT |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Opening each file in a folder using msoFileDialogFolderPicker | Excel Discussion (Misc queries) | |||
opening file from ftp folder | Excel Discussion (Misc queries) | |||
Opening an excel file from folder view | Excel Discussion (Misc queries) | |||
how to see file details without opening each folder | Excel Discussion (Misc queries) | |||
Opening a file from a set folder | Excel Programming |