Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Opening Multiple Files

I am trying to use a form that will allow me to select between three
different options of events:

Opening a single csv file, or
Opening multiple csv files from different locations, or
Open all csv files from multiple locations.

Then....I need to modify each file, one at a time,

Then...close each file as an excel file (preferably in the same location as
the csv file).
(Ultimately, I could move all the files into one folder as a temporary
work-around, but this wouldn't be my preference).

I am not sure how to code the later two options. Any help would be greatly
appreciated.

Mike S.



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default Opening Multiple Files

If you process all the files the same way, maybe displaying the file open dialog
until they hit cancel would work.

They can change to as many folders and select as many .csv files as they need.

Option Explicit
Option Base 1
Sub testme()

Dim myFileNames As Variant
Dim AllMyFileNames() As String
Dim iCtr As Long
Dim TotalFiles As Long

ReDim AllMyFileNames(1 To 1)
TotalFiles = 0
Do
myFileNames = Application.GetOpenFilename _
(filefilter:="CSV Files, *.csv", MultiSelect:=True)

If IsArray(myFileNames) Then
TotalFiles = TotalFiles + UBound(myFileNames)
ReDim Preserve AllMyFileNames(1 To TotalFiles)

For iCtr = UBound(myFileNames) To 1 Step -1
AllMyFileNames(TotalFiles + 1 - iCtr) = myFileNames(iCtr)
Next iCtr
Else
Exit Do
End If
Loop

If TotalFiles = 0 Then
MsgBox "try later!"
Exit Sub
End If

For iCtr = 1 To TotalFiles
MsgBox AllMyFileNames(iCtr)
'Workbooks.Open AllMyFileNames(iCtr)
Next iCtr

End Sub

Tell your users that they can select all the csv files in a folder by hitting
ctrl-a in that file|open dialog. (Excel seems to just ignore selected folders
when you do this.)



mike s wrote:

I am trying to use a form that will allow me to select between three
different options of events:

Opening a single csv file, or
Opening multiple csv files from different locations, or
Open all csv files from multiple locations.

Then....I need to modify each file, one at a time,

Then...close each file as an excel file (preferably in the same location as
the csv file).
(Ultimately, I could move all the files into one folder as a temporary
work-around, but this wouldn't be my preference).

I am not sure how to code the later two options. Any help would be greatly
appreciated.

Mike S.


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Opening Multiple Files

Hi Dave...

this option can work when I wouldn't have to go into too many
folders...however, sometimes I'll have up to a hundred+

Thanks for your input.

Mike S.

"Dave Peterson" wrote in message
...
If you process all the files the same way, maybe displaying the file open
dialog
until they hit cancel would work.

They can change to as many folders and select as many .csv files as they
need.

Option Explicit
Option Base 1
Sub testme()

Dim myFileNames As Variant
Dim AllMyFileNames() As String
Dim iCtr As Long
Dim TotalFiles As Long

ReDim AllMyFileNames(1 To 1)
TotalFiles = 0
Do
myFileNames = Application.GetOpenFilename _
(filefilter:="CSV Files, *.csv",
MultiSelect:=True)

If IsArray(myFileNames) Then
TotalFiles = TotalFiles + UBound(myFileNames)
ReDim Preserve AllMyFileNames(1 To TotalFiles)

For iCtr = UBound(myFileNames) To 1 Step -1
AllMyFileNames(TotalFiles + 1 - iCtr) = myFileNames(iCtr)
Next iCtr
Else
Exit Do
End If
Loop

If TotalFiles = 0 Then
MsgBox "try later!"
Exit Sub
End If

For iCtr = 1 To TotalFiles
MsgBox AllMyFileNames(iCtr)
'Workbooks.Open AllMyFileNames(iCtr)
Next iCtr

End Sub

Tell your users that they can select all the csv files in a folder by
hitting
ctrl-a in that file|open dialog. (Excel seems to just ignore selected
folders
when you do this.)



mike s wrote:

I am trying to use a form that will allow me to select between three
different options of events:

Opening a single csv file, or
Opening multiple csv files from different locations, or
Open all csv files from multiple locations.

Then....I need to modify each file, one at a time,

Then...close each file as an excel file (preferably in the same location
as
the csv file).
(Ultimately, I could move all the files into one folder as a temporary
work-around, but this wouldn't be my preference).

I am not sure how to code the later two options. Any help would be
greatly
appreciated.

Mike S.


--

Dave Peterson



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
MULTIPLE FILES OPENING STUDENT3215 New Users to Excel 0 July 18th 08 04:46 PM
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 .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 09:53 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"