export query to existing excel file

P

plt

Hi all,
I need a clue. I am stuck for days already.

I want to export a query to excel spreadsheet, supposedly the excel file
gets replaced each time I export the query. BUT what I found is the records
from the query is only replacing the rows in that spreadsheet and the remain
rows of the exisiting spreadsheet stay.

What do I do wrong? Could someone be kind to give me some clue. Is there any
setting that I miss? This suppose to be a simple program. Do I have to build
a function to delete the spreadsheet file prior exporting the query?

==================
Dim objXL As Object
Dim StrTxt As String

'xfer
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9,
"qryBacklogJobPlanning", _
"qryBacklogJobPlanning.xls"

DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9,
"tblUpdateSMU01", _
"qryBacklogJobPlanning.xls"


'open excel
Set objXL = CreateObject("Excel.Application")

StrTxt = Me!StrPathXLS

objXL.Workbooks.Open StrTxt & "\PTIMtcCalendar.xls"
objXL.Visible = True
==================

On TransferSpreadsheet Action, it suppose to replace the existing file (as
state in help:
Access creates a new spreadsheet when you export data from Access. If the
file name is the same as the name of an existing spreadsheet, Access replaces
the existing spreadsheet, unless you're exporting to an Excel version 5.0 or
later workbook. In that case, Access copies the exported data to the next
available new worksheet in the workbook)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top