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 ToolkitsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Importing / Linking / August 2006

Tip: Looking for answers? Try searching our database.

Export Access table without fieldnames

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
LAlbee - 25 Aug 2006 14:50 GMT
How do I go about exporting a table into excel without including the
fieldnames in the first row of data?
Klatuu - 25 Aug 2006 16:45 GMT
Neither the TransferSpreadsheet nor the OutPutTo methods will do this.  Your
only option (other than opening the spreadsheet and deleting the row with the
field names) is to use Automation to open the spreadsheet as an Excel object
in Access and use the CopyFromRecordset method of the Range object in the
Excel Object Model to load the data into Excel.

> How do I go about exporting a table into excel without including the
> fieldnames in the first row of data?
LAlbee - 25 Aug 2006 16:49 GMT
Thanks, can you give me any more details on how to accomplish this, I don't
know  much about VB.

> Neither the TransferSpreadsheet nor the OutPutTo methods will do this.  Your
> only option (other than opening the spreadsheet and deleting the row with the
[quoted text clipped - 4 lines]
> > How do I go about exporting a table into excel without including the
> > fieldnames in the first row of data?
Klatuu - 25 Aug 2006 17:26 GMT
If you are not familiar with VBA, it will be very difficult for you to use
this approach.  It really does take some fairly advanced VBA skills to
accomplish.  This is because using Automation to control Excel, if not done
correctly, can create additional instances of Excel in the Task Manager
Processes tab and cause the user to not be able to use Excel.

Here is some sample code from one of my applications.  I extracted those
lines of code that are pertinent; however, this may not be complete.  It will
give you an idea of what is required to manipulate Excel from Access.

Dim xlApp As Object             'Application Object
Dim xlBook As Object            'Workbook Object
Dim xlSheet As Object           'Worksheet Object
Dim blnExcelWasNotRunning As Boolean

'Set up the necessary objcts
   On Error Resume Next    ' Defer error trapping.
   Set xlApp = GetObject(, "Excel.Application")
   If Err.Number <> 0 Then
       blnExcelWasNotRunning = True
       Set xlApp = CreateObject("excel.application")
   Else
       DetectExcel
   End If
   Err.Clear    ' Clear Err object in case error occurred.
   On Error GoTo Build_XL_Report_ERR
   xlApp.DisplayAlerts = False
   xlApp.Interactive = False
   xlApp.ScreenUpdating = False
   Set xlBook = xlApp.Workbooks.Add
   Set xlSheet = xlBook.ActiveSheet

'Create the Recordset
   Set qdf = CurrentDb.QueryDefs("qselSCCBhdr")
   qdf.Parameters(0) = Me.cboResource
   qdf.Parameters(1) = Me.cboPeriod
   Set rstItms = qdf.OpenRecordset(dbOpenSnapshot, dbReadOnly)

'Be sure there are records to process
   rstItms.MoveLast
   rstItms.MoveFirst
   lngItmCount = rstItms.RecordCount
   If lngItmCount = 0 Then
       MsgBox "No Data Found For This Report", vbInformation + vbOKOnly,
"Data Error"
       GoTo Build_XL_Report_Exit
   End If

   xlSheet.Cells(2, 1).CopyFromRecordset rstItms

   xlBook.Close
   If blnExcelWasNotRunning = True Then
       xlApp.Quit
   Else
       xlApp.DisplayAlerts = True
       xlApp.Interactive = True
       xlApp.ScreenUpdating = True
   End If
   Set xlSheet = Nothing
   Set xlBook = Nothing
   Set xlApp = Nothing
   rstItms.Close
   Set rstItms = Nothing
--------------------------------
Sub DetectExcel()
' Procedure dectects a running Excel and registers it.
   Const WM_USER = 1024
   Dim hWnd As Long
' If Excel is running this API call returns its handle.
   hWnd = FindWindow("XLMAIN", 0)
   If hWnd = 0 Then    ' 0 means Excel not running.
       Exit Sub
   Else
   ' Excel is running so use the SendMessage API
   ' function to enter it in the Running Object Table.
       SendMessage hWnd, WM_USER + 18, 0, 0
   End If
End Sub

> Thanks, can you give me any more details on how to accomplish this, I don't
> know  much about VB.
[quoted text clipped - 7 lines]
> > > How do I go about exporting a table into excel without including the
> > > fieldnames in the first row of data?
 
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



©2010 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.