473,407 Members | 2,676 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

Cmdbutton to Quit excel/userform/vba?

I want to create a Command button that will allow the user to save their work and totally close out of excel and their user form. Any ideas on the code for this.
Jul 27 '10 #1

✓ answered by Guido Geurs

Close the workbook =

Expand|Select|Wrap|Line Numbers
  1. Workbooks("BOOK1.XLS").Close SaveChanges:=True
If You also want to exit Excel:

Expand|Select|Wrap|Line Numbers
  1. Private Sub CommandButton1_Click()
  2. Dim w As Workbook
  3.    For Each w In Application.Workbooks
  4.        w.Save
  5.    Next w
  6.    Application.Quit
  7. End Sub

2 4009
Guido Geurs
767 Expert 512MB
Close the workbook =

Expand|Select|Wrap|Line Numbers
  1. Workbooks("BOOK1.XLS").Close SaveChanges:=True
If You also want to exit Excel:

Expand|Select|Wrap|Line Numbers
  1. Private Sub CommandButton1_Click()
  2. Dim w As Workbook
  3.    For Each w In Application.Workbooks
  4.        w.Save
  5.    Next w
  6.    Application.Quit
  7. End Sub
Jul 28 '10 #2
for vb 6

end

for C++ and 4 or 5

me.end
or me.close
Jul 28 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Mike | last post by:
Please help. I am using object.quit in an attempt to quit an excel application that I started with createobject ("Excel.Application"). The code executes, but does not stop the application. When...
1
by: Mike | last post by:
Can anyone tell me why the following code fails to quit Excel for me. If I comment out the four lines that reference the workbook, Excel closes. excel = CreateObject("excel.application")...
1
by: u7djo | last post by:
Hi, I'm currently building a function in Access that creates an Excel spreadsheet but it doesn't look like the Excel object is being destroyed correctly as the Excel module is still showing in the...
6
by: Matthew Wieder | last post by:
I have the following requirements: Build a stand-alone C# application that asks the user to click in a cell in an Excel spreadsheet, and then displays the address of that cell in the C#...
16
by: LP | last post by:
Hello, I am trying to use .NET with Excel. I installed Office 2003 and selected ..NET programming suport option, so it installed all those PIA, as MS sugests. But I can not find a way to destroy...
7
by: SteveS | last post by:
I'm attempting to close EXCEL from within my VB.NET application. Using the excel object library to write data to my spreadsheet is working fine but when I try to quit application object it does not...
2
by: ChrisFrohlich | last post by:
I have been trying to use the Office PIA's to write an ASP.NEt page to: 1. Open a template workbook 2. Populate some data 3. Save the file back to the server 4. Quit Excel and free up Memory I...
1
by: garry.oxnard | last post by:
Can anyone help me to solve a problem which involves switching from Access to Excel (then back to Access) programatically please? I have an Excel template which, on open, also opens an Access...
0
by: liam_jones | last post by:
I'm very new to Python, well IronPython to precise, and have been having problems when using Excel. The problem I'm having is the closing of my Excel object. I'm able to successfully quit the...
4
by: tomy01 | last post by:
Can anyone please show me how to multipy(user input) four text boxes of user form 1 with four text boxes of user form 2 and store the value in any cell .Thank you. (Userform1.TextBox1.Value =...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.