Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Olivia Towery
 
Posts: n/a
Default Excel Server Object won't overwrite

I am using the CreateObject("Excel.Application") to create a workbook from
three separate tables in a sql db. This works great and compiles three
separate sheets to one workbook. The following lines name and add the
workbook to the directory:

fName = "" & strfile & ".xls"

xls.ActiveWorkbook.SaveAs server.MapPath(".") & "\" & fName
xls.Application.Quit

What do I need to add to make the object overwrite the existing file?

--
Olivia Towery


  #2   Report Post  
Dave Peterson
 
Posts: n/a
Default

you have a line like:

set xls = createobject("excel.application")
(Or its equivalent)

xls.displayalerts = false
'your code to save/overwrite
xls.displayalerts = true

(Do you actually need the .application in xls.application.quit??)

Olivia Towery wrote:

I am using the CreateObject("Excel.Application") to create a workbook from
three separate tables in a sql db. This works great and compiles three
separate sheets to one workbook. The following lines name and add the
workbook to the directory:

fName = "" & strfile & ".xls"

xls.ActiveWorkbook.SaveAs server.MapPath(".") & "\" & fName
xls.Application.Quit

What do I need to add to make the object overwrite the existing file?

--
Olivia Towery


--

Dave Peterson
  #3   Report Post  
Michael Harris \(MVP\)
 
Posts: n/a
Default

Olivia Towery wrote:
I am using the CreateObject("Excel.Application") to create a workbook
from three separate tables in a sql db. This works great and
compiles three separate sheets to one workbook. The following lines
name and add the workbook to the directory:

fName = "" & strfile & ".xls"

xls.ActiveWorkbook.SaveAs server.MapPath(".") & "\" & fName
xls.Application.Quit

What do I need to add to make the object overwrite the existing file?



You could avoid the overwite by using FSO to explicitly check for the
existence of the file to be overwitten first and delete it if it exits
before calling the SaveAs method.


--
Michael Harris
Microsoft MVP Scripting
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Please ask follow-up questions via the original newsgroup thread.



Reply
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
Multiple people accessing an Excel file from a server at once. UABCSA Excel Discussion (Misc queries) 1 May 2nd 05 05:41 PM
how to convert GETPIVOTDATA from excel 2000 to excel 2002... Need_help_on_excel Excel Worksheet Functions 1 March 15th 05 01:08 AM
How Do I open an excel file without Excel Viewer support CocoriteBallGiants Excel Discussion (Misc queries) 2 February 4th 05 10:50 PM
VB Automation is Whacking out my Excel Environment Joseph Geretz Excel Discussion (Misc queries) 2 December 29th 04 03:49 PM
Excel 2003 Database Driver Visual FoxPro 7 on Server 2003. Cindy Winegarden Excel Discussion (Misc queries) 0 November 28th 04 12:07 AM


All times are GMT +1. The time now is 09:04 AM.

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

About Us

"It's about Microsoft Excel"