Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Modules / DAO / VBA / December 2006

Tip: Looking for answers? Try searching our database.

Importing multiple worksheets

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Allen_N - 08 Dec 2006 04:49 GMT
Here's one for the uber-gurus.

I need to import multiple worksheets from the same workbook into 1 table.
(The data comprise more than 65,536 records, so they are split over several
worksheets.) I can do it this way, but it's a bit clumsy:

...
   nWorkSheets = GetNoWorkSheets(strPath)
   DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel8, _
                                              strTabUnavail, strPath, True,
""
   If nWorkSheets > 1 Then
       Call MsgBox("The workbook contains more than 1 sheet. " & vbCrLf _
                   & "You will need to import the remaining " & vbCrLf _
                   & "sheets manually, then close/open the view.", _
                   vbOKOnly, "ImportExcelReport()")
   End If
End Sub

Function GetNoWorkSheets(strPath) As Long
   Dim objXL As Excel.Application
   Dim ws As Excel.Worksheet
     
   Set objXL = New Excel.Application
   With objXL
       .Visible = False
       .Workbooks.Open (strPath)
       GetNoWorkSheets = .Sheets.Count
       .ActiveWorkbook.Close
   End With
End Function

I can't see a way to tell TransferSpreadsheet to use a particular worksheet;
it just grabs the 1st one. Am I missing something? Or, is there a hack, using
the API or something?
Alex Dybenko - 08 Dec 2006 11:04 GMT
Hi,
have a look here:
http://support.microsoft.com/kb/210379/en-us

Signature

Best regards,
___________
Alex Dybenko (MVP)
http://alexdyb.blogspot.com
http://www.PointLtd.com

> Here's one for the uber-gurus.
>
[quoted text clipped - 35 lines]
> using
> the API or something?
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.