Announcement

Collapse
No announcement yet.

Close Excel using COM without promt to save

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Close Excel using COM without promt to save

    Does anybody know if it is possible to close Excel without being asked to save the changes to the spreadsheet?

    I have an application that pushes data into various cells in Excel, allows it to make various calculations, reads results from other cells and then closes Excel using the commands:

    OBJECT CALL oExcelApp.ActiveWindow.Close
    OBJECT CALL oExcelApp.Quit

    However this results in a message box "Do you want to save the changes to xxxxx.xls?". I never want to save the spreadsheet. Excel is hidden as it is opened so there are no clues to the user that Excel is performing the calculations apart from this message box.

    Appreciate any help you can give me.

    Thanks

    Nick

  • #2
    There's probably a more elegant solution, but you could always use COM to save to worksheet to a dummy file. Then close Excel and delete the dummy file.

    Comment


    • #3
      I know this came up here about a month ago, and there was some kind of thing you could do

      It may have been this......

      Code:
      'Enumeration XlSaveAction
      %xlDoNotSaveChanges                                     = &H00000002
      %xlSaveChanges                                          = &H00000001
      ...
      INTERFACE DISPATCH ExcelWorkbook
      .....
      
          MEMBER CALL CLOSE<&H00000115>(OPTIONAL IN SaveChanges AS VARIANT<&H00000000>, _
                  OPTIONAL IN Filename AS VARIANT<&H00000001>, OPTIONAL IN RouteWorkbook AS VARIANT<&H00000002>)
      MCM
      Michael Mattias
      Tal Systems (retired)
      Port Washington WI USA
      [email protected]
      http://www.talsystems.com

      Comment


      • #4
        Thanks Michael, that looks like it will do the job for me.

        Nick

        Comment


        • #5
          Take a look at the Excel "DisplayAlerts" method. You can turn off the annoying prompt from there as well.
          Later...

          JR

          "When governments fear the people there is liberty. When people fear the government there is tyranny." - Thomas Jefferson

          Comment


          • #6
            >Take a look at the Excel "DisplayAlerts" method

            THAT's the one I (now) recall from a month ago.

            That may have been in the context of the way Excel handles ".csv" files... where it always asks if you want to save changes, even if you haven't made any changes (Excel has done that forever), but am certain it was something to do with "display alert" which was the solution.

            MCM
            Michael Mattias
            Tal Systems (retired)
            Port Washington WI USA
            [email protected]
            http://www.talsystems.com

            Comment


            • #7
              Originally posted by John R. Heathcote View Post
              Take a look at the Excel "DisplayAlerts" method. You can turn off the annoying prompt from there as well.
              Thanks John, working perfectly now.

              Nick

              Comment

              Working...
              X