473,378 Members | 1,671 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

access 97 importing specific excel worksheets

hello,

i have two worksheets that i need to import from a workbook that has a
total of 5 worksheets. i tried to use this line of code but i run into
an error message that it cannot find the object/worksheet "1989" due
to invalid parameter or name?

how does one import the specific worksheets without including the
ranges since the whole worksheet needs to be imported?

DoCmd.TransferSpreadsheet acImport, 8, "tbl1989",
"H:\Default\Processing Spreadsheet_ACCESS.xls", True, "1989"
DoCmd.TransferSpreadsheet acImport, 8, "tbl1993",
"H:\Default\Processing Spreadsheet_ACCESS.xls", True, "1993"

thanks in advance jung
Nov 12 '05 #1
2 3224
pi******@yahoo.fr (JMCN) wrote in message news:<27**************************@posting.google. com>...
hello,

i have two worksheets that i need to import from a workbook that has a
total of 5 worksheets. i tried to use this line of code but i run into
an error message that it cannot find the object/worksheet "1989" due
to invalid parameter or name?

how does one import the specific worksheets without including the
ranges since the whole worksheet needs to be imported?

DoCmd.TransferSpreadsheet acImport, 8, "tbl1989",
"H:\Default\Processing Spreadsheet_ACCESS.xls", True, "1989"
DoCmd.TransferSpreadsheet acImport, 8, "tbl1993",
"H:\Default\Processing Spreadsheet_ACCESS.xls", True, "1993"

thanks in advance jung


Jung,

how about something like this:

Option Compare Database
Option Explicit

Public Sub ImportXLS(ByVal strFile As String, ByVal strWorksheetName
As String)

'original from: http://www.mvps.org/access/general/gen0008.htm
'modified slightly...

DoCmd.TransferSpreadsheet transfertype:=acImport, _
tablename:="tblSheet1", _
FileName:=strFile, Hasfieldnames:=True, _
Range:=strWorksheetName & "!"
End Sub

I tested it with an Excel file with 3 worksheets and imported two of
them and it worked fine....

e.g.

importxls "C:\test.xls","Sheet2"
importxls "C:\test.xls","Sheet3"

HTH,
Pieter
Nov 12 '05 #2
pi********@hotmail.com (Pieter Linden) wrote in message news:<bf**************************@posting.google. com>...
pi******@yahoo.fr (JMCN) wrote in message news:<27**************************@posting.google. com>...
hello,

i have two worksheets that i need to import from a workbook that has a
total of 5 worksheets. i tried to use this line of code but i run into
an error message that it cannot find the object/worksheet "1989" due
to invalid parameter or name?

how does one import the specific worksheets without including the
ranges since the whole worksheet needs to be imported?

DoCmd.TransferSpreadsheet acImport, 8, "tbl1989",
"H:\Default\Processing Spreadsheet_ACCESS.xls", True, "1989"
DoCmd.TransferSpreadsheet acImport, 8, "tbl1993",
"H:\Default\Processing Spreadsheet_ACCESS.xls", True, "1993"

thanks in advance jung


Jung,

how about something like this:

Option Compare Database
Option Explicit

Public Sub ImportXLS(ByVal strFile As String, ByVal strWorksheetName
As String)

'original from: http://www.mvps.org/access/general/gen0008.htm
'modified slightly...

DoCmd.TransferSpreadsheet transfertype:=acImport, _
tablename:="tblSheet1", _
FileName:=strFile, Hasfieldnames:=True, _
Range:=strWorksheetName & "!"
End Sub

I tested it with an Excel file with 3 worksheets and imported two of
them and it worked fine....

e.g.

importxls "C:\test.xls","Sheet2"
importxls "C:\test.xls","Sheet3"

HTH,
Pieter


thanks pieter!!! it worked but i modified the code a little bit. i
just did not know how to write the tab/worksheet.

DoCmd.TransferSpreadsheet acImport, 8, "tbl1989",
"H:\Default\ProcessingDF.xls", True, "'1989'!"
DoCmd.TransferSpreadsheet acImport, 8, "tbl1993",
"H:\Default\ProcessingDF.xls", True, "'1993'!"
Nov 12 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: sridevi | last post by:
Hello How to export data from ms-access database to excel worksheet using ASP. mainly i need to export data to multiple worksheets. it is very urgent to us. i have a sample code which works...
2
by: JMCN | last post by:
hello, i have two worksheets that i need to import from a workbook that has a total of 5 worksheets. i tried to use this line of code but i run into an error message that it cannot find the...
7
by: Darren | last post by:
I have been attempting to create a reservation planning form in excel that imports Data from an Access database and inserts that information automaticly into the correct spreed sheet and the...
11
by: Mr. Smith | last post by:
Hello all, My code can successfully open, write to, format and save several worksheets in a workbook then save it by a given name, close and quit excel. My problem is that if I try and do it...
2
by: Bill Agee | last post by:
I am having difficulting importing an Excel spreadsheet into my Access program using VBA I want to use the last argument to specify the worksheet name which is RTA. I get an error which says that...
4
by: Anthony Cuttitta Jr. | last post by:
I'm working on some procedures where Access queries are exported to Excel, and then later on, those same workbooks are openned, and I need to target a specific original sheet. Sometimes there will...
1
by: madeleine.macphail | last post by:
All I'm currently attempting to move us from a spreadsheet based system to a database system. The first phase is to import the data on a regular basis from the spreadsheets to get the database...
1
by: thadson | last post by:
Hi, I'm trying to import specific cells from MS Excel 2000 spreadsheets to MS Access 2000 tables then move the spreadsheets to a different directory. I'm very new to this and I'm having trouble...
6
by: JFKJr | last post by:
Hello everyone, the following is the Access VBA code which opens an excel spreadsheet and creates combo boxes dynamically. And whenever a user selects a value in a combo box, I am trying to pass...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.