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

x
?
Solved

DoCmd.TransferSpreadsheet acExport

Posted on 2008-10-17
2
Medium Priority
?
1,832 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 93

Accepted Solution

by:
Patrick Matthews earned 2000 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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

I was prompted to write this article after the recent World-Wide Ransomware outbreak. For years now, System Administrators around the world have used the excuse of "Waiting a Bit" before applying Security Patch Updates. This type of reasoning to me …
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

715 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