LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22
Default Access 2003: transferspreadsheet writes over existing spreadsheet

I have code that creates a new workbook and saves it under a new name, and
transfers the results of a query and formats the sheet and renames it. Then I
have 2 more transferspreadsheet commands that are supposed to transfer to 2
new worksheets and rename them. Unfortunately, it has the bizarre behavior of
somehow writing over the existing spreadsheet, adding another sheet named
after the
query being transferred, but with garbled data in this new sheet, and now,
ruined data in the existing sheet. Has anyone ever come across this behavior
before? Here's my code:

DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9,
"qryQTreeAndAppChanges", strNewWkBk

If ExcelIsRunning Then
Set xlObj = GetObject(, "Excel.Application")
Else
Set xlObj = CreateObject("Excel.Application")
End If

Set wkBk = xlObj.Workbooks.Open(strNewWkBk)

With wkBk
.ActiveSheet.Name = "QTree and Owner Changes"
.Save
End With

************************************************** **************
(a lot of formatting stuff successfully executes)
The following ruins the 1st sheet:
************************************************** **************

DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "qryDataNew",
strNewWkBk
Set wkBk = xlObj.Workbooks.Open(strNewWkBk)
With wkBk
.Sheets("qryDataNew").Name = Format(dtNew, "yymmdd") & " Data"
.Close True
End With
Set wkBk = Nothing
xlObj.Quit

DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "qryDataOld",
strNewWkBk
Set wkBk = xlObj.Workbooks.Open(strNewWkBk)
With wkBk
.Sheets("qryDataOld").Name = Format(dtOld, "yymmdd") & " Data"
.Sheets(Format(dtNew, "yymmdd") & " Data").Delete
.Close True
End With
Set wkBk = Nothing
xlObj.Quit

Any suggestions would be appreciated,

--
Bill Reed

"If you can't laugh at yourself, laugh at somebody else"

Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...excel/200804/1

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel 2003 problem opening existing spreadsheet [email protected] Excel Discussion (Misc queries) 4 April 29th 07 03:46 AM
access a website from excel 2003 spreadsheet Ricardo New Users to Excel 0 October 25th 06 11:31 PM
download existing spreadsheets into another existing spreadsheet lbierer Excel Discussion (Misc queries) 2 September 24th 06 08:36 PM
Ruby access to an existing Spreadsheet with complex formulae seabird20 Excel Discussion (Misc queries) 0 August 2nd 06 07:43 PM
Transfer to an existing Access Table Secret Squirrel Excel Discussion (Misc queries) 0 March 17th 06 11:31 PM


All times are GMT +1. The time now is 10:46 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"