Solved

close other workbook - close excel - do not save

Posted on 2014-03-08
5
830 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
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…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa‚Ķ

624 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