I am trying to write a program which will open and close a spreadsheet. I am using the following code to do open the spreadsheet:
To close the spreadsheet I am using this code:Code:Dim xlapp As excel.Application Dim xlstudentbook As excel.Workbook Set xlapp = New excel.Application Set xlstudentbook = xlapp.Workbooks.Open(App.Path & "\Students.xls")
This all appears to work the first time the program closes the spreadsheet, however when the program closes it for the second time I still get a overwrite prompt.Code:Application.DisplayAlerts = False xlstudentbook.Saved = True xlstudentbook.Save xlstudentbook.Close Set xlstudentbook = Nothing Set xlapp = Nothing
How can I avoid this prompt and just save the spreadsheet with no questions asked?
Thanks in advance.




Reply With Quote