Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

exporting into a file with header in access

Posted on 2015-02-24
3
Medium Priority
?
92 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
[X]
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
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 2000 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

Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

Question has a verified solution.

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

Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

722 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