Connecting Tech Pros Worldwide Help | Site Map

Import different excel-files in one access-table

MD
Guest
 
Posts: n/a
#1: Mar 26 '07
Hello,

I need to import a sheet of 884 different excel-file with same lay-
out.
The sheet name is 'Totaal' and is the same in all different files.

Is there a script (module) in order to:
1. create a table with all the different names of the 884 files
2. create the import queryfor the 884 different files, but also
mentioning the file name of the excel-file in a colomn

Can anybody help? I tried a little bit, but it is not really
working...

M

DavidB
Guest
 
Posts: n/a
#2: Mar 26 '07

re: Import different excel-files in one access-table


What is the final objective?

On Mar 26, 3:22 pm, "MD" <deboism...@hotmail.comwrote:
Quote:
Hello,
>
I need to import a sheet of 884 different excel-file with same lay-
out.
The sheet name is 'Totaal' and is the same in all different files.
>
Is there a script (module) in order to:
1. create a table with all the different names of the 884 files
2. create the import queryfor the 884 different files, but also
mentioning the file name of the excel-file in a colomn
>
Can anybody help? I tried a little bit, but it is not really
working...
>
M

MD
Guest
 
Posts: n/a
#3: Mar 26 '07

re: Import different excel-files in one access-table


To analyse the data, combine it with other data and to run queries on
it in access.

On 26 mrt, 21:31, "DavidB" <j...@yahoo.comwrote:
Quote:
What is the final objective?
>
On Mar 26, 3:22 pm, "MD" <deboism...@hotmail.comwrote:
>
>
>
Quote:
Hello,
>
Quote:
I need to import a sheet of 884 different excel-file with same lay-
out.
The sheet name is 'Totaal' and is the same in all different files.
>
Quote:
Is there a script (module) in order to:
1. create a table with all the different names of the 884 files
2. create the import queryfor the 884 different files, but also
mentioning the file name of the excel-file in a colomn
>
Quote:
Can anybody help? I tried a little bit, but it is not really
working...
>
Quote:
M- Tekst uit oorspronkelijk bericht niet weergeven -
>
- Tekst uit oorspronkelijk bericht weergeven -

Aivars
Guest
 
Posts: n/a
#4: Mar 26 '07

re: Import different excel-files in one access-table


forget excel.move your data to access.
before I was trying ti use excel for everything. But, as soon as
discovered the power of access there is no way back

MD wrote:
Quote:
To analyse the data, combine it with other data and to run queries on
it in access.
>
On 26 mrt, 21:31, "DavidB" <j...@yahoo.comwrote:
Quote:
What is the final objective?

On Mar 26, 3:22 pm, "MD" <deboism...@hotmail.comwrote:


Quote:
Hello,
Quote:
I need to import a sheet of 884 different excel-file with same lay-
out.
The sheet name is 'Totaal' and is the same in all different files.
Quote:
Is there a script (module) in order to:
1. create a table with all the different names of the 884 files
2. create the import queryfor the 884 different files, but also
mentioning the file name of the excel-file in a colomn
Quote:
Can anybody help? I tried a little bit, but it is not really
working...
Quote:
M- Tekst uit oorspronkelijk bericht niet weergeven -
- Tekst uit oorspronkelijk bericht weergeven -
DavidB
Guest
 
Posts: n/a
#5: Mar 26 '07

re: Import different excel-files in one access-table


You want all 884 excel workbook in one table in access?

On Mar 26, 3:37 pm, "MD" <deboism...@hotmail.comwrote:
Quote:
To analyse the data, combine it with other data and to run queries on
it in access.
>
On 26 mrt, 21:31, "DavidB" <j...@yahoo.comwrote:
>
>
>
Quote:
What is the final objective?
>
Quote:
On Mar 26, 3:22 pm, "MD" <deboism...@hotmail.comwrote:
>
Quote:
Quote:
Hello,
>
Quote:
Quote:
I need to import a sheet of 884 different excel-file with same lay-
out.
The sheet name is 'Totaal' and is the same in all different files.
>
Quote:
Quote:
Is there a script (module) in order to:
1. create a table with all the different names of the 884 files
2. create the import queryfor the 884 different files, but also
mentioning the file name of the excel-file in a colomn
>
Quote:
Quote:
Can anybody help? I tried a little bit, but it is not really
working...
>
Quote:
Quote:
M- Tekst uit oorspronkelijk bericht niet weergeven -
>
Quote:
- Tekst uit oorspronkelijk bericht weergeven -- Hide quoted text -
>
- Show quoted text -

DavidB
Guest
 
Posts: n/a
#6: Mar 26 '07

re: Import different excel-files in one access-table


he was asking how to import the excel into access! DOH. Its kind of
stuipid to re-enter 884 workbooks worth of data thats already in excel
if it can be imported! :)

On Mar 26, 3:53 pm, "Aivars" <aiva...@apollo.lvwrote:
Quote:
forget excel.move your data to access.
before I was trying ti use excel for everything. But, as soon as
discovered the power of access there is no way back
>
>
>
MD wrote:
Quote:
To analyse the data, combine it with other data and to run queries on
it in access.
>
Quote:
On 26 mrt, 21:31, "DavidB" <j...@yahoo.comwrote:
Quote:
What is the final objective?
>
Quote:
Quote:
On Mar 26, 3:22 pm, "MD" <deboism...@hotmail.comwrote:
>
Quote:
Quote:
Hello,
>
Quote:
Quote:
I need to import a sheet of 884 different excel-file with same lay-
out.
The sheet name is 'Totaal' and is the same in all different files.
>
Quote:
Quote:
Is there a script (module) in order to:
1. create a table with all the different names of the 884 files
2. create the import queryfor the 884 different files, but also
mentioning the file name of the excel-file in a colomn
>
Quote:
Quote:
Can anybody help? I tried a little bit, but it is not really
working...
>
Quote:
Quote:
M- Tekst uit oorspronkelijk bericht niet weergeven -
>
Quote:
Quote:
- Tekst uit oorspronkelijk bericht weergeven -- Hide quoted text -
>
- Show quoted text -

MD
Guest
 
Posts: n/a
#7: Mar 26 '07

re: Import different excel-files in one access-table


Indeed, all in the same file...

On 26 mrt, 21:59, "DavidB" <j...@yahoo.comwrote:
Quote:
You want all 884 excel workbook in one table in access?
>
DavidB
Guest
 
Posts: n/a
#8: Mar 26 '07

re: Import different excel-files in one access-table


I didnt ask same file I asked same TABLE... :)

On Mar 26, 4:01 pm, "MD" <deboism...@hotmail.comwrote:
Quote:
Indeed, all in the same file...
>
On 26 mrt, 21:59, "DavidB" <j...@yahoo.comwrote:
>
>
>
Quote:
You want all 884 excel workbook in one table in access?- Hide quoted text -
>
- Show quoted text -

MD
Guest
 
Posts: n/a
#9: Mar 26 '07

re: Import different excel-files in one access-table


Sorry, i ment same table
so yes: in 1 table

DavidB
Guest
 
Posts: n/a
#10: Mar 26 '07

re: Import different excel-files in one access-table


On Mar 26, 4:22 pm, "MD" <deboism...@hotmail.comwrote:
Quote:
Sorry, i ment same table
so yes: in 1 table
OK so we basically have a whole boat load of identically formatted
excel workbooks that you want to import into a single access table...
Are the excel files all names the same or do they have unique names?


MD
Guest
 
Posts: n/a
#11: Mar 26 '07

re: Import different excel-files in one access-table


they have unique names, so 884 different names

Don Leverton
Guest
 
Posts: n/a
#12: Mar 28 '07

re: Import different excel-files in one access-table


Well, this is not EXACTLY what you are asking for ... it does a bit more
actually.
I had written this to do much the same thing you are doing, but I wanted a
visual reference to confirm that the imports had been done ... along with
quick access to the actual XL file (via a hyperlink field in a subform) if I
wanted to check. Call me paranoid. :)

So what I did was:
1.) Create a table called "tblFileNames"
2.) An unbound form called "frmImportXL Files"
3.) A BOUND (to tblFileNames) subform called "sbfFilesImported"

I'd start by putting all 884 of those XLS files in thier own directory,
seperate from everything else.
================================================== ===================
Private Sub cmdImportMergeXL_Click()

Dim MyDB As DAO.Database
Set MyDB = CurrentDb

Dim rstFiles As DAO.Recordset
Set rstFiles = MyDB.OpenRecordset("tblFileNames")

Dim MyDir As String
Dim MyFile As String
Dim MyPath As String
Dim FileSpec As String
Dim Msg As String

Dim intFC As Integer 'File Counter
intFC = 0

'Start by browsing for the drive/directory containing the XL files
'Requires Terry Kreft's "BrowseFolder" API from
http://www.mvps.org/access/api/api0002.htm
'-----------------------------------------------------------------
MyDir = BrowseFolder("Find the directory containing the desired files")

FileSpec = MyDir & "\*.xls"
MyPath = MyDir & "\" & Dir(FileSpec)
MyFile = Dir(FileSpec)
'This section loops thru the files in the directory one at a time
'and adds the imported filenames to the table
'-----------------------------------------------------------------
Do While Len(MyFile) 0

With rstFiles
.AddNew
!FilePath = "#file://" & MyPath & "#"
'This converts the filepath string to a hyperlink,
'which allows the user to open the XL file from a subform link
.Update
End With

DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel97,
"tblXLSimport", MyFile, True


MyFile = Dir 'Import the next XL file in the directory.

If Len(MyFile) 0 Then
MyPath = MyDir & "\" & MyFile
End If
intFC = intFC + 1
Loop

Set rstFiles = Nothing
Set MyDB = Nothing

Msg = ""
Msg = Msg & intFC
Msg = Msg & " XL filenames have been imported."
MsgBox Msg

Me.Refresh 'Refreshes the subform that now contains the imported filenames.

End Sub
================================================== ========================

HTH,
Don

"MD" <deboismarc@hotmail.comwrote in message
news:1174941731.709968.156650@l77g2000hsb.googlegr oups.com...
Quote:
they have unique names, so 884 different names
>

Closed Thread