Results 1 to 4 of 4

Thread: Excel in VB.Net

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Mar 2004
    Posts
    19

    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

  2. #2
    Fanatic Member pvbangera's Avatar
    Join Date
    Sep 2001
    Location
    Mumbai, India
    Posts
    961
    is there any property as SetWarning or Warning?? If yes, try to set it False

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Mar 2004
    Posts
    19
    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.

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Mar 2004
    Posts
    19

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width