Excel 2003 - VBA - Closing workbooks without error

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
 
D

Dave Peterson

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
 
C

Craig Brandt

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
 
D

Dave Peterson

application.displayalerts = false
ActiveWorkbook.Close savechanges:=false 'or true
application.displayalerts = true
 
C

Craig Brandt

Dave,

Thank You,

Craig

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top