Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Overwrite Excel File when using DTS to Export

Status
Not open for further replies.

kim1

Programmer
Nov 7, 2001
77
0
0
CA
Hy guys,

Does DTS has an option to overwrite the file when I want to Export data from a Table to an Excel File.

I try to run it every night, and DTS adds at the bottom of the file, it does not overwrite it. Is there anything I can do?

thanks for your help.

Kim Kim
 
I had the same problem and I've added an ActiveX script (in VBscript) before the export start, that cleans the worksheet.
 
HI,
I hope this script will help (it works for me on MSSQL 2000):

Function Main()
Set xls = CreateObject("Excel.Application")
xls.visible = false
xls.Workbooks.Open "c:\work\scripts\xls\Other\Currencies & Countries.XLS"
Set book = xls.Workbooks(1)

For each foo in book.Worksheets
foo.activate
foo.range("A2:F500").delete
next
book.close true
xls.quit

Main = DTSTaskExecResult_Success
End Function


Another way, add two steps before insert (connection to Excel file):
1) drop table`NReport`

Good Luck
2)create table `NReport`
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top