Solved

close other workbook - close excel - do not save

Posted on 2014-03-08
5
824 Views
Last Modified: 2014-03-13
We have a data work book that is used to copy data from Access.  

The data is linked to a second workbook
We use VBA code to save the second workbook and break the links to the data work book
We want to close the data workbook without saving, after the code has run

How do I close the Data workbook from within the  code on the second workbook?
I do not want any alerts.
It would also be ok to quit excel with no alerts as the second workbook was saved earlier
0
Comment
Question by:AMixMaster
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 81

Assisted Solution

by:byundt
byundt earned 300 total points
ID: 39915417
You might try code like this:
Sub Closeout()
Workbooks("Data.xlsx").Close SaveChanges:=False
Application.DisplayAlerts = False
Application.Quit     'Close Excel and all open workbooks
End Sub

Open in new window

0
 

Author Comment

by:AMixMaster
ID: 39916117
We are on the right track
except when I use Workbooks().Close SaveChanges:=False
it activates the workbook but does not close it and the code does not continue
I should mention that the workbook we are trying to close is an .XLS
0
 

Author Comment

by:AMixMaster
ID: 39928206
I've requested that this question be closed as follows:

Accepted answer: 0 points for AMixMaster's comment #a39916376
Assisted answer: 300 points for byundt's comment #a39915417
Assisted answer: 0 points for AMixMaster's comment #a39916117

for the following reason:

Found the solution on a member website and it worked like a charm :)
0
 
LVL 81

Accepted Solution

by:
byundt earned 300 total points
ID: 39916519
Workbooks.Close doesn't activate a workbook. It closes it. And if the SaveChanges parameter is set to False, then no warning about an unsaved workbook will be displayed.

Workbooks.Close should work with .xls files as well as .xlsx or .xlsm. It has been part of the VBA language since the beginning.

When you run Chip Pearson's code, you will find that Excel remains open. Application.Quit will close all open workbooks and then quit the Excel application. If the workbooks being closed have been changed since they were last saved, you will see a warning message asking whether to save them first. Application.DisplayAlerts = False will suppress those warning messages.
0

Featured Post

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question