Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 367
Default VB Statement for opening multiple files of type?

I am trying to write a VB script in Excel that will open up all files with a
..rpt extension, then format them in a particular way, then save them as .xls
files in a separate folder. I have been able to script the formatting of the
opened files, but I would like Excel to open all the files in a certain
folder that has the .rpt extension. Any suggestions on how to write this?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default VB Statement for opening multiple files of type?

Sub HandleRPT()
Dim sPath as String, sName as String
Dim bk as Workbook, s as String
sPath = "C:\Myfolder\"

sName = Dir(sPath & "*.rpt")
do while sName < ""
set bk = workbooks.Open(sPath & sName)
' process bk
s = left(sName,len(sName)-4)
bk.SaveAs sPath & s & ".xls", xlWorkbookNormal
bk.close Savechanges:=False
sName = Dir
Loop
End sub

--
Regards,
Tom Ogilvy


"Jason" wrote:

I am trying to write a VB script in Excel that will open up all files with a
.rpt extension, then format them in a particular way, then save them as .xls
files in a separate folder. I have been able to script the formatting of the
opened files, but I would like Excel to open all the files in a certain
folder that has the .rpt extension. Any suggestions on how to write this?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 367
Default VB Statement for opening multiple files of type?

This is poetic. It works fine now. Thanks!



"Tom Ogilvy" wrote:

Sub HandleRPT()
Dim sPath as String, sName as String
Dim bk as Workbook, s as String
sPath = "C:\Myfolder\"

sName = Dir(sPath & "*.rpt")
do while sName < ""
set bk = workbooks.Open(sPath & sName)
' process bk
s = left(sName,len(sName)-4)
bk.SaveAs sPath & s & ".xls", xlWorkbookNormal
bk.close Savechanges:=False
sName = Dir
Loop
End sub

--
Regards,
Tom Ogilvy


"Jason" wrote:

I am trying to write a VB script in Excel that will open up all files with a
.rpt extension, then format them in a particular way, then save them as .xls
files in a separate folder. I have been able to script the formatting of the
opened files, but I would like Excel to open all the files in a certain
folder that has the .rpt extension. Any suggestions on how to write this?

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 multiple files into one workbook, but multiple worksheets.... Andy Excel Discussion (Misc queries) 0 January 24th 07 06:34 PM
opening multiple .txt files from multiple folders Corben Excel Discussion (Misc queries) 3 March 16th 06 12:43 AM
How can I view files chronologically when opening multiple files Stevilsize Excel Discussion (Misc queries) 3 July 26th 05 12:49 AM
Opening Multiple Files mike s Excel Programming 2 December 2nd 04 06:42 AM
opening multiple .csv files from the web Ryan Cooney Excel Programming 0 July 31st 03 08:18 PM


All times are GMT +1. The time now is 11:54 AM.

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"