Solved

close other workbook - close excel - do not save

Posted on 2014-03-08
5
779 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
  • 3
  • 2
5 Comments
 
LVL 80

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: 39916376
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 80

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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
This is pretty cool.  The purpose of this VB Script is to help you document where JAR (Java ARchive) files and specifically java class files are located so that you can address issues seen with a client or that you can speak intelligently with a dev…
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

759 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now