Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
JT JT is offline
external usenet poster
 
Posts: 234
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default 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
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
Opening each file in a folder using msoFileDialogFolderPicker Ayo Excel Discussion (Misc queries) 2 January 23rd 13 10:03 PM
opening file from ftp folder PBISMaryland Excel Discussion (Misc queries) 1 September 16th 09 11:37 AM
Opening an excel file from folder view JS Excel Discussion (Misc queries) 0 March 17th 09 06:29 PM
how to see file details without opening each folder Junkanoo Princess Excel Discussion (Misc queries) 1 May 7th 08 03:25 PM
Opening a file from a set folder Mart Excel Programming 2 October 18th 04 11:38 AM


All times are GMT +1. The time now is 10:44 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"