Solved

close other workbook - close excel - do not save

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…
Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

920 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

14 Experts available now in Live!

Get 1:1 Help Now