Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default load several ASCII files in different worksheets

HI
How can I load all files contained in one folder into a new worksheet for
each file?
How can I select the folder before as it is not static?
Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 863
Default load several ASCII files in different worksheets

You'll probably need to open each one, then move or copy the sheet into the
master workbook.

Record the steps as you do this manually, then somebody can help with
modifications to make it operate on all files in a directory (.TXT? .CSV?)


On Mon, 14 Mar 2005 15:57:01 -0800, bandy2000
wrote:

HI
How can I load all files contained in one folder into a new worksheet for
each file?
How can I select the folder before as it is not static?
Thanks


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default load several ASCII files in different worksheets

I recorded it already one time but it is all set to exactly the selected
folder and the file name nothing is random. So only for this file it can be
reused.


"Myrna Larson" wrote:

You'll probably need to open each one, then move or copy the sheet into the
master workbook.

Record the steps as you do this manually, then somebody can help with
modifications to make it operate on all files in a directory (.TXT? .CSV?)


On Mon, 14 Mar 2005 15:57:01 -0800, bandy2000
wrote:

HI
How can I load all files contained in one folder into a new worksheet for
each file?
How can I select the folder before as it is not static?
Thanks



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 863
Default load several ASCII files in different worksheets

Yes, of course that would be the case. You must post the code you have and
tell us how you want to select the directory and the files to be processed,
i.e. what the file extensions are, etc.


On Mon, 14 Mar 2005 20:37:04 -0800, bandy2000
wrote:

I recorded it already one time but it is all set to exactly the selected
folder and the file name nothing is random. So only for this file it can be
reused.


"Myrna Larson" wrote:

You'll probably need to open each one, then move or copy the sheet into the
master workbook.

Record the steps as you do this manually, then somebody can help with
modifications to make it operate on all files in a directory (.TXT? .CSV?)


On Mon, 14 Mar 2005 15:57:01 -0800, bandy2000
wrote:

HI
How can I load all files contained in one folder into a new worksheet for
each file?
How can I select the folder before as it is not static?
Thanks




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default load several ASCII files in different worksheets

what I wanted to do is to select a folder and automatically all files with
the ".res" suffix will be processed. The folder should be selected in a
regular file dialog.

this is the code for the opening of the file that I recorded earlier:
Sub Macro_open_file()
'
' Macro_open_file Macro
' Macro recorded 3/13/2005 '

'
Workbooks.OpenText Filename:= _
"C:\Measurement Results\FolderName\FileName.res" _
, Origin:=437, StartRow:=1, DataType:=xlDelimited, TextQualifier:= _
xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True,
Semicolon:=False, _
Comma:=False, Space:=False, Other:=False, FieldInfo:=Array(Array(1,
1), _
Array(2, 1)), TrailingMinusNumbers:=True

I'm not sure how I will have to do the copy and paste operation and how I
should record it.

"Myrna Larson" wrote:

Yes, of course that would be the case. You must post the code you have and
tell us how you want to select the directory and the files to be processed,
i.e. what the file extensions are, etc.


On Mon, 14 Mar 2005 20:37:04 -0800, bandy2000
wrote:

I recorded it already one time but it is all set to exactly the selected
folder and the file name nothing is random. So only for this file it can be
reused.


"Myrna Larson" wrote:

You'll probably need to open each one, then move or copy the sheet into the
master workbook.

Record the steps as you do this manually, then somebody can help with
modifications to make it operate on all files in a directory (.TXT? .CSV?)


On Mon, 14 Mar 2005 15:57:01 -0800, bandy2000
wrote:

HI
How can I load all files contained in one folder into a new worksheet for
each file?
How can I select the folder before as it is not static?
Thanks






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 252
Default load several ASCII files in different worksheets

The vba function you want to start with is
GetOpenFilename

See the Help for this.

"bandy2000" wrote:

what I wanted to do is to select a folder and automatically all files with
the ".res" suffix will be processed. The folder should be selected in a
regular file dialog.

this is the code for the opening of the file that I recorded earlier:
Sub Macro_open_file()
'
' Macro_open_file Macro
' Macro recorded 3/13/2005 '

'
Workbooks.OpenText Filename:= _
"C:\Measurement Results\FolderName\FileName.res" _
, Origin:=437, StartRow:=1, DataType:=xlDelimited, TextQualifier:= _
xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True,
Semicolon:=False, _
Comma:=False, Space:=False, Other:=False, FieldInfo:=Array(Array(1,
1), _
Array(2, 1)), TrailingMinusNumbers:=True

I'm not sure how I will have to do the copy and paste operation and how I
should record it.

"Myrna Larson" wrote:

Yes, of course that would be the case. You must post the code you have and
tell us how you want to select the directory and the files to be processed,
i.e. what the file extensions are, etc.


On Mon, 14 Mar 2005 20:37:04 -0800, bandy2000
wrote:

I recorded it already one time but it is all set to exactly the selected
folder and the file name nothing is random. So only for this file it can be
reused.


"Myrna Larson" wrote:

You'll probably need to open each one, then move or copy the sheet into the
master workbook.

Record the steps as you do this manually, then somebody can help with
modifications to make it operate on all files in a directory (.TXT? .CSV?)


On Mon, 14 Mar 2005 15:57:01 -0800, bandy2000
wrote:

HI
How can I load all files contained in one folder into a new worksheet for
each file?
How can I select the folder before as it is not static?
Thanks




  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default load several ASCII files in different worksheets

Following is the code that allows me already to select a folder and to count
the files with the "*.res" and than open a specific file as a new workbook.
This should be no problem to be embedded into a For Loop that processes all
files contained in the folder.
But what I actually want is to open the files as a new worksheet.
How can I do this?



With Application.FileDialog(msoFileDialogFolderPicker)
.Show
selection = .SelectedItems.Count
Path = .SelectedItems(selection)
End With



Set fs = Application.FileSearch
With fs
.LookIn = Path
.Filename = "*.res"
If .Execute 0 Then
MsgBox "There were " & .FoundFiles.Count & _
" file(s) found."
Else
MsgBox "There were no files found."
End If
Set AllFilesFound = .FoundFiles

End With

MsgBox AllFilesFound(5)


Workbooks.OpenText Filename:= _
AllFilesFound(5) _
, Origin:=437, StartRow:=1, DataType:=xlDelimited, TextQualifier:= _
xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True,
Semicolon:=False, _
Comma:=False, Space:=False, Other:=False, FieldInfo:=Array(Array(1,
1), _
Array(2, 1)), TrailingMinusNumbers:=True


"gocush" wrote:

The vba function you want to start with is
GetOpenFilename

See the Help for this.

"bandy2000" wrote:

what I wanted to do is to select a folder and automatically all files with
the ".res" suffix will be processed. The folder should be selected in a
regular file dialog.

this is the code for the opening of the file that I recorded earlier:
Sub Macro_open_file()
'
' Macro_open_file Macro
' Macro recorded 3/13/2005 '

'
Workbooks.OpenText Filename:= _
"C:\Measurement Results\FolderName\FileName.res" _
, Origin:=437, StartRow:=1, DataType:=xlDelimited, TextQualifier:= _
xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True,
Semicolon:=False, _
Comma:=False, Space:=False, Other:=False, FieldInfo:=Array(Array(1,
1), _
Array(2, 1)), TrailingMinusNumbers:=True

I'm not sure how I will have to do the copy and paste operation and how I
should record it.

"Myrna Larson" wrote:

Yes, of course that would be the case. You must post the code you have and
tell us how you want to select the directory and the files to be processed,
i.e. what the file extensions are, etc.


On Mon, 14 Mar 2005 20:37:04 -0800, bandy2000
wrote:

I recorded it already one time but it is all set to exactly the selected
folder and the file name nothing is random. So only for this file it can be
reused.


"Myrna Larson" wrote:

You'll probably need to open each one, then move or copy the sheet into the
master workbook.

Record the steps as you do this manually, then somebody can help with
modifications to make it operate on all files in a directory (.TXT? .CSV?)


On Mon, 14 Mar 2005 15:57:01 -0800, bandy2000
wrote:

HI
How can I load all files contained in one folder into a new worksheet for
each file?
How can I select the folder before as it is not static?
Thanks




  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default load several ASCII files in different worksheets

Turn on the macro recorder and go to Date=Get External Data (or Import
external data) and import your file. Turn off the macro recorder. Now you
can modify this code to allow you to pass the selected file name or pass the
name in a loop.

--
Regards,
Tom Ogilvy

"bandy2000" wrote in message
...
Following is the code that allows me already to select a folder and to

count
the files with the "*.res" and than open a specific file as a new

workbook.
This should be no problem to be embedded into a For Loop that processes

all
files contained in the folder.
But what I actually want is to open the files as a new worksheet.
How can I do this?



With Application.FileDialog(msoFileDialogFolderPicker)
.Show
selection = .SelectedItems.Count
Path = .SelectedItems(selection)
End With



Set fs = Application.FileSearch
With fs
.LookIn = Path
.Filename = "*.res"
If .Execute 0 Then
MsgBox "There were " & .FoundFiles.Count & _
" file(s) found."
Else
MsgBox "There were no files found."
End If
Set AllFilesFound = .FoundFiles

End With

MsgBox AllFilesFound(5)


Workbooks.OpenText Filename:= _
AllFilesFound(5) _
, Origin:=437, StartRow:=1, DataType:=xlDelimited, TextQualifier:=

_
xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True,
Semicolon:=False, _
Comma:=False, Space:=False, Other:=False,

FieldInfo:=Array(Array(1,
1), _
Array(2, 1)), TrailingMinusNumbers:=True


"gocush" wrote:

The vba function you want to start with is
GetOpenFilename

See the Help for this.

"bandy2000" wrote:

what I wanted to do is to select a folder and automatically all files

with
the ".res" suffix will be processed. The folder should be selected in

a
regular file dialog.

this is the code for the opening of the file that I recorded earlier:
Sub Macro_open_file()
'
' Macro_open_file Macro
' Macro recorded 3/13/2005 '

'
Workbooks.OpenText Filename:= _
"C:\Measurement Results\FolderName\FileName.res" _
, Origin:=437, StartRow:=1, DataType:=xlDelimited,

TextQualifier:= _
xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True,
Semicolon:=False, _
Comma:=False, Space:=False, Other:=False,

FieldInfo:=Array(Array(1,
1), _
Array(2, 1)), TrailingMinusNumbers:=True

I'm not sure how I will have to do the copy and paste operation and

how I
should record it.

"Myrna Larson" wrote:

Yes, of course that would be the case. You must post the code you

have and
tell us how you want to select the directory and the files to be

processed,
i.e. what the file extensions are, etc.


On Mon, 14 Mar 2005 20:37:04 -0800, bandy2000
wrote:

I recorded it already one time but it is all set to exactly the

selected
folder and the file name nothing is random. So only for this file

it can be
reused.


"Myrna Larson" wrote:

You'll probably need to open each one, then move or copy the

sheet into the
master workbook.

Record the steps as you do this manually, then somebody can help

with
modifications to make it operate on all files in a directory

(.TXT? .CSV?)


On Mon, 14 Mar 2005 15:57:01 -0800, bandy2000
wrote:

HI
How can I load all files contained in one folder into a new

worksheet for
each file?
How can I select the folder before as it is not static?
Thanks






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
How do I load files from a CD? Jamie Thompson[_2_] Excel Discussion (Misc queries) 3 January 21st 09 10:22 PM
how do i up load an ascii file to excel to do labels in words dotties Excel Discussion (Misc queries) 3 November 8th 06 07:39 PM
ASCII files ...please help riggi Excel Discussion (Misc queries) 5 June 27th 06 04:25 AM
How to load these XLS files Jako[_31_] Excel Programming 5 July 18th 04 11:45 PM
Excel 2000 importing huge ASCII files into different sheets Goran Stjepanovic Excel Programming 2 February 25th 04 09:30 AM


All times are GMT +1. The time now is 01:15 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"