Excel 2003 - VBA - Closing workbooks without error

  • Thread starter Thread starter Craig Brandt
  • Start date Start date
C

Craig Brandt

Hi guys:

WorkBook "A" - The primary workbook I am working with.
WorkBook "B".Sheet "B" - the worksheet that has data I need on a worksheet
in workbook "A"

Workbook "A" is open to a blank worksheet, Open WorkBook "B" Sheet "B". copy
the data off the page, paste the data in the worksheet in Workbook "A", then
want to close WorkBook "B" Sheet "B".

' Open Returns Document
RTNFileName = Application.GetOpenFilename(Title:="Open SpreadSheet to
Import")
Workbooks.Open (RTNFileName)
RTNName = ActiveWorkbook.Name
Cells.Copy
' Go back to previously opened document
Workbooks(LTRName).Activate
ActiveSheet.Paste
Workbooks(RTNName).Activate
ActiveWorkbook.Close

I cannot find out how to close a wookbook without it asking if I want to
save the data that I copied.

Thanks for any help,
Craig
 
ActiveWorkbook.Close savechanges:=false 'or true

Craig said:
Hi guys:

WorkBook "A" - The primary workbook I am working with.
WorkBook "B".Sheet "B" - the worksheet that has data I need on a worksheet
in workbook "A"

Workbook "A" is open to a blank worksheet, Open WorkBook "B" Sheet "B". copy
the data off the page, paste the data in the worksheet in Workbook "A", then
want to close WorkBook "B" Sheet "B".

' Open Returns Document
RTNFileName = Application.GetOpenFilename(Title:="Open SpreadSheet to
Import")
Workbooks.Open (RTNFileName)
RTNName = ActiveWorkbook.Name
Cells.Copy
' Go back to previously opened document
Workbooks(LTRName).Activate
ActiveSheet.Paste
Workbooks(RTNName).Activate
ActiveWorkbook.Close

I cannot find out how to close a wookbook without it asking if I want to
save the data that I copied.

Thanks for any help,
Craig
 
Dave:

The question that excel presents me with is "There is a large amount of
information on the clipboard. Do you want to be able to paste this
information into another program later?"


The suggested solution doesn't help with this situation. Any other ideas?

Craig
 
application.displayalerts = false
ActiveWorkbook.Close savechanges:=false 'or true
application.displayalerts = true
 
Dave,

Thank You,

Craig

Dave Peterson said:
application.displayalerts = false
ActiveWorkbook.Close savechanges:=false 'or true
application.displayalerts = true
 
Back
Top