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: 1
Default Excel VBA-How to open several delmited files & SaveAs Excel files

I have several delimited files (.xl) in the same directory and would
like to open all of them. I would like to save each file in the same
name except as an Excel file. I have macros that open all files in a
directory, save all open workbooks and open delimited files given a
name (in an array in the macro). Any suggestions would be
appreciated!

Below is what I currently have to open the files, notice how each file
name must be specified in the array. I basically want to get rid of
this necessity.

Sub Open1()
Dim varr As Variant
Dim wkbk1 As Workbook
Dim wkbk As Workbook
Dim i As Long
Dim sh1 As Workbook
Dim sName As String

varr = Array("12 15 03 01 NIST610.xl", _
"12 15 03 02 NIST610.xl", _
"12 15 03 03 NIST610.xl", _
"12 15 03 04 MACS1.xl")

Set wkbk = ActiveWorkbook
For i = LBound(varr) To UBound(varr)
Workbooks.OpenText Filename:=tName, _
Origin:=xlWindows, StartRow:=1, DataType:=xlDelimited,
TextQualifier:= _
xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True,
Semicolon:=False, _
Comma:=True, Space:=False, Other:=False, FieldInfo:=Array(Array(1,
1), _
Array(2, 1), Array(3, 1), Array(4, 1), Array(5, 1), Array(6, 1),
Array(7, 1), Array(8, 1), _
Array(9, 1), Array(10, 1), Array(11, 1), Array(12, 1), Array(13,
1), Array(14, 1), Array(15 _
, 1), Array(16, 1), Array(17, 1), Array(18, 1), Array(19, 1),
Array(20, 1), Array(21, 1), _
Array(22, 1), Array(23, 1), Array(24, 1))

Set wkbk1 = ActiveWorkbook

Next
End Sub

I'll also include my code to open all files within a directory. Can I
modify this to open all delimited files and automatically go through
the delimited-to-excel file wizard?

Sub OpenAll()
Dim sName As String
sName = Dir("D:\Key West\New Data\*.xls")
Do While sName < ""
Workbooks.Open Filename:=sName
sName = Dir()
Loop
End Sub

Thank you!

Ryan


---
Message posted from http://www.ExcelForum.com/

 
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
emailing files from excel, the files will not go until I open up . joe New Users to Excel 2 September 18th 09 02:12 PM
how do I toggle between 2 open excel files and leave both open Big D in Brighton Excel Discussion (Misc queries) 1 November 6th 08 04:28 PM
How to change default Open/Files of Type to "Microsoft Excel Files Tammy Excel Discussion (Misc queries) 2 January 14th 08 11:06 PM
I can't open any excel files Laura Gravina Excel Discussion (Misc queries) 0 October 12th 06 08:26 PM
Excel files won't open Mason C Excel Discussion (Misc queries) 1 February 28th 06 09:26 AM


All times are GMT +1. The time now is 12:29 PM.

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"