-
Excel in VB.Net
I am trying to disable the "Save Changes" dialog
Here is the code I am using, everything works but I still get the "Save Changes" dialog.
Private Sub btApply_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btApply.Click
Dim WSheet
Dim FN As String
Dim sv As New SaveFileDialog
sv.CreatePrompt = False
sv.OverwritePrompt = False
FN = "C:\WS 2000 Simulator\Data\Data.xls"
EXL.Workbooks.Open(FN)
WSheet = EXL.Workbooks.Item(1).Worksheets("Sheet1")
With WSheet
.Cells(4, 3).Value = txtSystemName.Text
.Cells(5, 3).Value = txtSystemLocation.Text
.Cells(6, 3).Value = txtAdminEMail.Text
.Cells(7, 3).Value = cbCountry.Text
.Cells(8, 3).Value = lblWS2000Version.Text
End With
EXL.Workbooks.Close()
End Sub
Thanks for any help
-
is there any property as SetWarning or Warning?? If yes, try to set it False
-
Not that I could find, I get the same pop up window that you would get if you changed an Excel spreadsheet and just tried to close it without saving it first.
-
Solved
Got it, here is the modified code for anyone elce trying to do the samething.
This will open an Excel spreadsheet, modify it, then save it without the "Save Current" windows dialog.
Private Sub btApply_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btApply.Click
Dim WSheet
Dim FN As String
EXL.DisplayAlerts = False
FN = "C:\WS 2000 Simulator\Data\Data.xls"
EXL.Workbooks.Open(FN)
WSheet = EXL.Workbooks.Item(1).Worksheets("Sheet1")
With WSheet
.Cells(4, 3).Value = txtSystemName.Text
.Cells(5, 3).Value = txtSystemLocation.Text
.Cells(6, 3).Value = txtAdminEMail.Text
.Cells(7, 3).Value = cbCountry.Text
.Cells(8, 3).Value = lblWS2000Version.Text
End With
EXL.SaveWorkspace()
EXL.Workbooks.Close()
End Sub