Group:  Microsoft Access ยป microsoft.public.access.externaldata
Thread: export query to existing excel file

DotNetBag
.NET Development Newsgroups

HTVi
TV Discussion Newsgroups

Our Hot Pick: Rising Antivirus 2006 - Certified by TUV & Checkmark! Get 10% discount by entering this coupon code: ONDISCOUNT10
Rising Antivirus 2006

export query to existing excel file
plt 28.09.2006 10:02:02
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)

--
Appreciate any clue,
patar

Home | Search | Terms | Imprint | Contact
Newsgroups Reader - provided by WiredBox.Net