hobbes2103 Posted July 29, 2003 Posted July 29, 2003 Hi ! I have a form1 and when i press on button1 i want to open an existing Excel file, i write in it, i print it and then close it without saving changes. 'Opening the existing file Dim xlApp As Excel.Application Dim xlbook As Excel.Workbook Dim xlsheet As Excel.Worksheet xlApp = New Excel.Application xlbook = xlApp.Workbooks.Open(C:\Model.xls") xlsheet = xlApp.Sheets(1) xlsheet.Name = "Hello" '(Then comes all the writing in the sheet) 'Printing without saving xlsheet.PrintOut() xlApp.Quit() xlsheet = Nothing xlbook = Nothing xlApp = Nothing Now the problem is that when i execute the program, VB opens the files, writes an prints but when it closes the file i get the usual message from Excel asking me if i want to save the changes in the initial file. I don't want this message to appear, i want VB to automatically say "No" to it... How do i do that? Help is needed urgently... :eek: Thank you!!!!! Quote
JABE Posted July 29, 2003 Posted July 29, 2003 Try calling xlbook.Close(False) before xlApp.Quit(); the first param is SaveChanges. Haven't actually tried it though. Quote
Recommended Posts