473,394 Members | 1,794 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Save Excel file

Hello all

I open a template Excel file as following
-----------------------------
im xlApp As Object

Dim xlBook As Excel.Workbook

Dim xlSheet As Excel.Worksheet

xlApp = CreateObject("Excel.Application")

xlApp.Visible = True

xlBook = xlApp.Workbooks.Open("C:\Database\TempExcel\invoic e.xls")

xlSheet = xlBook.Worksheets(1)

---------------

Then I save this file as with a new name

Dim fileName As String = "C:\aNewFile.xls"

xlBook.SaveAs(fileName)

-------------

However, if there is existed file "aNewFile.xls", there is a message
informing that there is a file with the same name and ask me if I want to
replace it. I do not want to have this message and want my application
automatically replaces the old file. Coul you please tell me how to do that.

Thank you very much for your help

S.Hoa
Nov 21 '05 #1
2 3986
Shoa,
Why don't you test for the existing file and delete it before you do the
save.

Doug

"shoa" <so*@slingshot.co.nz> wrote in message
news:1118894312.202141@ftpsrv1...
Hello all

I open a template Excel file as following
-----------------------------
im xlApp As Object

Dim xlBook As Excel.Workbook

Dim xlSheet As Excel.Worksheet

xlApp = CreateObject("Excel.Application")

xlApp.Visible = True

xlBook = xlApp.Workbooks.Open("C:\Database\TempExcel\invoic e.xls")

xlSheet = xlBook.Worksheets(1)

---------------

Then I save this file as with a new name

Dim fileName As String = "C:\aNewFile.xls"

xlBook.SaveAs(fileName)

-------------

However, if there is existed file "aNewFile.xls", there is a message
informing that there is a file with the same name and ask me if I want to
replace it. I do not want to have this message and want my application
automatically replaces the old file. Coul you please tell me how to do that.
Thank you very much for your help

S.Hoa

Nov 21 '05 #2
With xlApp
.DisplayAlerts = False
xlBook.SaveAs("C:\aNewFile.xls")
.DisplayAlerts = True
End With

I think this should do it

Greetz Peter

--
Programming today is a race between software engineers striving to build
bigger and better idiot-proof programs, and the Universe trying to produce
bigger and better idiots. So far, the Universe is winning.
"shoa" <so*@slingshot.co.nz> schreef in bericht
news:1118894312.202141@ftpsrv1...
Hello all

I open a template Excel file as following
-----------------------------
im xlApp As Object

Dim xlBook As Excel.Workbook

Dim xlSheet As Excel.Worksheet

xlApp = CreateObject("Excel.Application")

xlApp.Visible = True

xlBook = xlApp.Workbooks.Open("C:\Database\TempExcel\invoic e.xls")

xlSheet = xlBook.Worksheets(1)

---------------

Then I save this file as with a new name

Dim fileName As String = "C:\aNewFile.xls"

xlBook.SaveAs(fileName)

-------------

However, if there is existed file "aNewFile.xls", there is a message
informing that there is a file with the same name and ask me if I want to
replace it. I do not want to have this message and want my application
automatically replaces the old file. Coul you please tell me how to do that.
Thank you very much for your help

S.Hoa

Nov 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: I Decker | last post by:
Hi all, Hope this is the right group. I am writing a program in c# to open create an excel document, enter some data, save it and then email it as an attachment. I have successfully created...
4
by: Jae | last post by:
I'm writing a web application that exports and imports excel files. The application gets a list of users and their info and displays it in a datagrid .The user then selects to save the file as a...
2
by: monsieur.marco | last post by:
Hi all, Does anybody know how to save localization in an excel workbook (C# 1.1)? I'm not sure this is possible, but I'm trying to do this so that numberColumns keep their format no matter what...
2
by: iloveprincess | last post by:
Hi, I'm developing windows application using VB.Net 2005. I would like to send 'save' message using 'SendMessage' API to the excel appication. I've already got a handle of the excel window with...
3
by: =?Utf-8?B?YXNkZg==?= | last post by:
Hello. I am making a web application with c# and am using this code: Response.ContentType = "application/x-excel"; Response.AddHeader("Content-Disposition", "attachment;filename=" +...
1
by: rn5a | last post by:
When users submit a Form with a SQL query, the resultset is retrieved from a MS-Access database table which is then exported to an MS-Excel worksheet. After the records get exported to MS-Excel, I...
7
by: shantanu | last post by:
Hi all i am trying to save a excel file as a tab delimited text file. can i do it some how? i using the code _sheet1.SaveAs(@"C:\PRP \PRPTemp.txt",Excel.XlFileFormat.xlTextWindows...
3
by: S_K | last post by:
Hi, I have a problem when I try to save a .CSV file from an ASP.NET web page and the client has Excel open already. The symptoms are: 1) The web page is currently displaying the Excel...
3
by: =?Utf-8?B?YzY3NjIyOA==?= | last post by:
Hi all, I have a question for you. I have a .csv file which has many lines of data. Each line has many data fields which are delimited by ",". Now I need to extract part of data from this...
3
by: evenlater | last post by:
I have an Access application on a terminal server. Sometimes my users need to export reports to pdf, rtf or xls files and save them to their own client device hard drives. They can do that right...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.