PC Review


Reply
Thread Tools Rate Thread

Code needed to open files one at a time

 
 
=?Utf-8?B?Sm9oblVL?=
Guest
Posts: n/a
 
      2nd Aug 2007
Hi All,
Gosh havent been on here for a while.
Okay - I have a folder that has 10 to 30 files that I need to open one at a
time and export info from each file to a master workbook, close and start on
the next until they have all been covered.

I am in need of a piece of code that can find and open (regardless of file
name) close and start on the next.

I can fill in the code that will export the data, its the opening the files
one at a time I cant do.

Anyone out there that can help?

Many thanks
John
 
Reply With Quote
 
 
 
 
=?Utf-8?B?VG9tIE9naWx2eQ==?=
Guest
Posts: n/a
 
      2nd Aug 2007
Dim sPath as String, sName as String
Dim bk as Workbook
sPath = "C:\Myfolder\"

sName = Dir(sPath & "*.xls")
do while sName <> ""
set bk = workbooks.Open(sPath & sName)


bk.close SaveChanges:=False
sName = Dir()
Loop

--
Regards,
Tom Ogilvy


"JohnUK" wrote:

> Hi All,
> Gosh havent been on here for a while.
> Okay - I have a folder that has 10 to 30 files that I need to open one at a
> time and export info from each file to a master workbook, close and start on
> the next until they have all been covered.
>
> I am in need of a piece of code that can find and open (regardless of file
> name) close and start on the next.
>
> I can fill in the code that will export the data, its the opening the files
> one at a time I cant do.
>
> Anyone out there that can help?
>
> Many thanks
> John

 
Reply With Quote
 
=?Utf-8?B?Sm9oblVL?=
Guest
Posts: n/a
 
      2nd Aug 2007
Hi Tom,
Many thanks, I will try this later and let you know how I get on.
Regards
John

"Tom Ogilvy" wrote:

> Dim sPath as String, sName as String
> Dim bk as Workbook
> sPath = "C:\Myfolder\"
>
> sName = Dir(sPath & "*.xls")
> do while sName <> ""
> set bk = workbooks.Open(sPath & sName)
>
>
> bk.close SaveChanges:=False
> sName = Dir()
> Loop
>
> --
> Regards,
> Tom Ogilvy
>
>
> "JohnUK" wrote:
>
> > Hi All,
> > Gosh havent been on here for a while.
> > Okay - I have a folder that has 10 to 30 files that I need to open one at a
> > time and export info from each file to a master workbook, close and start on
> > the next until they have all been covered.
> >
> > I am in need of a piece of code that can find and open (regardless of file
> > name) close and start on the next.
> >
> > I can fill in the code that will export the data, its the opening the files
> > one at a time I cant do.
> >
> > Anyone out there that can help?
> >
> > Many thanks
> > John

 
Reply With Quote
 
=?Utf-8?B?Sm9oblVL?=
Guest
Posts: n/a
 
      4th Aug 2007
Hi Tom,
Many thanks, It worked a treat.
Take care
Regards
John

"Tom Ogilvy" wrote:

> Dim sPath as String, sName as String
> Dim bk as Workbook
> sPath = "C:\Myfolder\"
>
> sName = Dir(sPath & "*.xls")
> do while sName <> ""
> set bk = workbooks.Open(sPath & sName)
>
>
> bk.close SaveChanges:=False
> sName = Dir()
> Loop
>
> --
> Regards,
> Tom Ogilvy
>
>
> "JohnUK" wrote:
>
> > Hi All,
> > Gosh havent been on here for a while.
> > Okay - I have a folder that has 10 to 30 files that I need to open one at a
> > time and export info from each file to a master workbook, close and start on
> > the next until they have all been covered.
> >
> > I am in need of a piece of code that can find and open (regardless of file
> > name) close and start on the next.
> >
> > I can fill in the code that will export the data, its the opening the files
> > one at a time I cant do.
> >
> > Anyone out there that can help?
> >
> > Many thanks
> > John

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
vba code needed to add .snp object files to powerpoint nimmis Microsoft Powerpoint 4 8th Jul 2008 09:03 PM
How do I get the code needed to open Microsoft Word? =?Utf-8?B?RGF2ZQ==?= Microsoft Access 3 18th Aug 2007 03:09 AM
Open Form based u pon a value from a test box; code needed =?Utf-8?B?RGlydHk3MEJpcmQ=?= Microsoft Access Forms 2 5th Dec 2005 08:43 PM
Code needed big time! oberon.black Microsoft Excel Programming 2 11th Sep 2005 10:22 PM
Code needed to open mdb file =?Utf-8?B?Y2xtZTRobHA=?= Microsoft Access 1 17th Mar 2005 08:31 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:15 AM.