Solved

DoCmd.TransferSpreadsheet acExport

Posted on 2008-10-17
2
1,830 Views
Last Modified: 2012-05-05
I am running the following script and it works.  The only thing is that it creates a new sheet in the excel workbook rather than over write the existing worksheet.  I need it to overwrite what is out there,,,
 
 
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, QryName, _
            "Z:\Documents\GL\Budget_09\Input_Sheets\Data\IS Budget Exp Sheets_2009.xls", True, QryName & "_payroll_roster"
           
Thank you
0
Comment
Question by:tom0523
[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
2 Comments
 
LVL 92

Accepted Solution

by:
Patrick Matthews earned 500 total points
ID: 22744663
I would try Excel automation:

Dim xlApp As Object, xlWb As Object, xlWs As Object
Dim rs As DAO.Recordset
Dim Counter As Long

Set rs = CurrentDb.OpenRecordset(QryName)
Set xlApp = CreateObject("Excel.Application")
Set xlWb = xlApp.Workbooks.Open("Z:\Documents\GL\Budget_09\Input_Sheets\Data\IS Budget Exp Sheets_2009.xls")
Set xlWs = xlWb.Worksheets.Add
With xlWs
    For Counter = 1 to rs.Fields.Count
        .Cells(1, Counter) = rs.Fields(Counter - 1)
    Next
    .Cells(2, 1).CopyFromRecordset rs
End With

xlWb.Save
xlWb.Close
Set xlWs = Nothing
Set xlWb = Nothing
xlApp.Quit
Set xlApp = Nothing
rs.Close
Set rs = Nothing
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
If you need to forecast numbers -- typically for finance -- the Windows and Mac versions of Excel 2016 have a basket of tools to get the job done.
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…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

617 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