From: S Shipley on 18 Mar 2010 14:36 I open a CSV file in Excel, Copy two columns of data, paste the data into another workbook and then I want to cloes the CSV file without getting a prompt about saving the data to the clipboard. I am using Application.ActiveWindow.Close (False) to close the file but I'm still getting the prompt to save the data. Is there another command I should use? Thanks, Sam
From: Dave Peterson on 18 Mar 2010 15:58 First, I don't go through the Windows collection. I just close the workbook. Dim CSVWkbk as workbook 'other code here 'open the csv file Workbooks.Open Filename:="somepath\somename.csv" set csvwkbk = activeworkbook 'the csv that was just opened 'do lots of work 'and close the workbook csvwkbk.close savechanges:=false And I don't get that prompt message. (Maybe you're closing the wrong window???) If this doesn't help, try: application.displayalerts = false Application.ActiveWindow.Close False application.displayalerts = true S Shipley wrote: > > I open a CSV file in Excel, Copy two columns of data, paste the data into > another workbook and then I want to cloes the CSV file without getting a > prompt about saving the data to the clipboard. > > I am using Application.ActiveWindow.Close (False) to close the file but I'm > still getting the prompt to save the data. Is there another command I should > use? > > Thanks, > Sam -- Dave Peterson
From: Wouter HM on 18 Mar 2010 16:36 Hi Sam, In addition to Dave's first sample: 'open the csv file Workbooks.Open Filename:="somepath\somename.csv" set csvwkbk = activeworkbook 'the csv that was just opened 'do lots of work 'mislead the workbook it is saved after changes csvwkbk.saved = true 'and close the workbook csvwkbk.close savechanges:=false HTH, Wouter
From: Dave Peterson on 18 Mar 2010 19:11 I don't recall ever having to mislead excel if I closed without saving changes. But if it helps the original poster, woohoo!!! Wouter HM wrote: > > Hi Sam, > > In addition to Dave's first sample: > > 'open the csv file > Workbooks.Open Filename:="somepath\somename.csv" > set csvwkbk = activeworkbook 'the csv that was just opened > > 'do lots of work > > 'mislead the workbook it is saved after changes > csvwkbk.saved = true > > 'and close the workbook > csvwkbk.close savechanges:=false > > HTH, > > Wouter -- Dave Peterson
|
Pages: 1 Prev: Macro Please Next: cell to have comma-delimited values based on text |