Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

exporting into a file with header in access

Posted on 2015-02-24
3
88 Views
Last Modified: 2016-02-12
How do you export from access into a excel file with the excel file with a header already formatted.


I want to be able to export the data starting from row 15 in the excel file and how do you call the same file and still be able to export data again and again
0
Comment
Question by:Jass Saini
3 Comments
 
LVL 22

Expert Comment

by:Kelvin Sparks
ID: 40628865
To do this, you need to make Access start an instance of Excel, and use Excel vba to write to the worksheet.

Typically I'd use code something like

Dim xl As Object
Dim xlw As Object
Dim xls As Object

Set xl = CreateObject("Excel.Application")
xl.DisplayAlerts = False
xl.Visible = False

Set xlw = xl.Workbooks.Add
xlw.SaveAs sWB, FileFormat:=56 ''Fileformat 56 is the excel 97-2003 file format for xls files

Set xls = xlw.Worksheets("Sheet1")
xls.Name = "Record Sheet"
xls.SELECT
xls.Activate

From there you need to manage what cell or cells you are using and what you want to happen.


Kelvin
0
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 500 total points
ID: 40628900
try this codes, replace objects as appropriate with your actual object names.

Sub exp2XL()
Dim rs As DAO.Recordset
Dim xlObj As Object
Dim Sheet As Object

Set rs = CurrentDb.OpenRecordset("select * from queryName")

If rs.EOF Then Exit Sub

    Set xlObj = CreateObject("Excel.Application")
    xlObj.Workbooks.open "c:\folder\excelfile.xlsx"
      
      Set Sheet = xlObj.activeworkbook.Sheets("sheet1")
      
       Sheet.Range("A15").CopyFromRecordset rs  'copy the data
      
    Set Sheet = Nothing
    xlObj.Quit
    Set xlObj = Nothing
      
end sub
0
 

Author Closing Comment

by:Jass Saini
ID: 40642735
Thanks
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

861 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question