By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,514 Members | 1,308 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,514 IT Pros & Developers. It's quick & easy.

How to avoid dialogue box while saveas an Excel file in VB.Net

P: n/a
Hi ALL,
In VB.Net,
I create an Excel as followed:
Dim excelapp As New Excel.Application
Dim oWB As Excel.Workbook
Dim oSheet As Excel.Worksheet

' Get a new workbook.
oWB = excelapp.Workbooks.Add
oSheet = CType(oWB.ActiveSheet, Excel.Worksheet)
Dim i As Integer
For i = 0 To 100
oSheet.Range("A" & (i + 1).ToString).Value = i
oSheet.Range("B" & (i + 1).ToString).Formula = "=A" & (i +
1).ToString
Next
oSheet.SaveAs("C:\Test.xls")
While saving the new fiel, if the file "Test.xls" already exists, a
dialogue box will pop up asking if overwrite that file. However, I
don't want to see this box, I want to just overwrite that file. How
should I do then?
Thanks!

Mar 14 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Try

excelapp.DisplayAlerts = False
oSheet.SaveAs("C:\Test.xls")
excelapp.DisplayAlerts = True

Kim

--
digipede - Many legs make light work.
Grid computing for the real world.
http://www.digipede.net
http://krgreenlee.blogspot.com

"mi*******@gmail.com" wrote:
Hi ALL,
In VB.Net,
I create an Excel as followed:
Dim excelapp As New Excel.Application
Dim oWB As Excel.Workbook
Dim oSheet As Excel.Worksheet

' Get a new workbook.
oWB = excelapp.Workbooks.Add
oSheet = CType(oWB.ActiveSheet, Excel.Worksheet)
Dim i As Integer
For i = 0 To 100
oSheet.Range("A" & (i + 1).ToString).Value = i
oSheet.Range("B" & (i + 1).ToString).Formula = "=A" & (i +
1).ToString
Next
oSheet.SaveAs("C:\Test.xls")
While saving the new fiel, if the file "Test.xls" already exists, a
dialogue box will pop up asking if overwrite that file. However, I
don't want to see this box, I want to just overwrite that file. How
should I do then?
Thanks!

Mar 15 '06 #2

P: n/a
Great!!!
Thanks, Kim.

Mar 15 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.