Microsoft SQL Server
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesMicrosoft SQL Server

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old July 30th, 2003, 09:11 AM
alex401 alex401 is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 4 alex401 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
import

Hello,
I have a large number of spreadsheets to import into access 2000. Does someone know precisely how to write a macro, for instance, to do this?

Reply With Quote
  #2  
Old August 5th, 2003, 05:54 AM
stumpy's Avatar
stumpy stumpy is offline
May contain nuts.
Dev Articles Regular (2000 - 2499 posts)
 
Join Date: Aug 2002
Location: Sydney, AU
Posts: 2,058 stumpy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 8 m 57 sec
Reputation Power: 9
Send a message via ICQ to stumpy Send a message via MSN to stumpy
I'm not entirely sure if this is possible, but you may be able to make an ODBC connection out of your Excel sheet. Then, in Access, you can create a new DB using the ODBC connection.

Just an idea.

Reply With Quote
  #3  
Old August 11th, 2003, 07:26 AM
jdarwin jdarwin is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 7 jdarwin User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Hello,

In my opinion you do not need any macro to import your spreadsheets to Access.

Go to

File -> Get External Data -> Import

on the Access 200 menu bar. Here you can import youe spreadsheet/xls files.

Reply With Quote
  #4  
Old August 11th, 2003, 08:33 AM
rdoekes rdoekes is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Location: Strasbourg, France
Posts: 181 rdoekes User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 m 20 sec
Reputation Power: 7
Send a message via AIM to rdoekes Send a message via Yahoo to rdoekes
if the number of spreadsheets is too large to manually do a file->import

you could think about a vbs script in combination with ADO to do the work for you. This only if the spreadsheets have exactly the same table format, and the worksheets are named the same, and preferrably all the files in the same folder

This vbs script needs to do the following:
- Instantiates Scripiting.FileSystemObject
- Makes a folder object
- Grabs all the files in this folder
- Loop through the file collection
- ADO/ODBC Connection to each file in this folder
- Create recordset for the worksheet which contains the data
- Insert this recordset in the Access database, also using ADO/ODBC

This process of course only if the number of sheets is large enough to warrent a automated process, preferrably if the process is repetitive.
__________________
- Rogier Doekes

Reply With Quote
  #5  
Old August 13th, 2003, 05:09 AM
jdarwin jdarwin is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 7 jdarwin User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Hi,

Well, yes for large number of spreadsheets following steps and VB code could help without any need of ADO or ODBC code.

1. Copy or move all your spreadsheets to a directory, say in d:\work. Make sure only the required spreadsheets are present here, remove any other files.

2. Change directory to d:\work with "d:" then "cd\work".

3. Create a text file containing file names of all your spreadsheets with "dir/b > sheets.txt"

4. Copy and paste following Visual Basic code into MS Access "modules" as a new sub.

Sub ImportSheets()
Dim TextLine
Open "d:\work\sheets.txt" For Input As #1
Do While Not EOF(1)
Line Input #1, TextLine
c = c + 1
Debug.Print TextLine
Debug.Print
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel7, "Sheet" & Trim(Str(c)), TextLine, True
Loop
Close #1
End Sub

5. You may need to change "acSpreadsheetTypeExcel7" option to the matching Excel/Lotus spreadsheet version of your files you need to import.

6. Open an immediate window in Access VB editor, and run this subroutine with "call ImportSheets" in the Immediate Window.

7. After successful execution all your spreadsheets will be imported to Access tables with names Sheet1, Sheet2, ...

Please reply me if this worked for you.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesMicrosoft SQL Server > import


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT