Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Need some help with Exit Event

Hi All- I've got an exit button in a user form that I want to
accomplish the following with when clicked-
1. Prompt the user to see if they want to save the form and associated
workbook.
2. If yes to save then ask to save as and where.
3. Exit form and excel.

Presently I have the following code associated with the button.
Obviously it's inoperable at this point. I've searched quite a bit to
find some similiar code, without much luck. Any help would be greatly
appreciated. Thanks.

Private Sub BtnExit_Click()
End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Need some help with Exit Event

Matt,

Try something like

Private Sub btnExit_Click()

Dim FName As Variant
FName = Application.GetSaveAsFilename(, "Excel Files
(*.xls),*.xls")
If FName = False Then
Exit Sub
End If
ThisWorkbook.SaveAs Filename:=FName
Me.Hide
Application.Quit
End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com




"Matt" wrote in message
oups.com...
Hi All- I've got an exit button in a user form that I want to
accomplish the following with when clicked-
1. Prompt the user to see if they want to save the form and
associated
workbook.
2. If yes to save then ask to save as and where.
3. Exit form and excel.

Presently I have the following code associated with the button.
Obviously it's inoperable at this point. I've searched quite a
bit to
find some similiar code, without much luck. Any help would be
greatly
appreciated. Thanks.

Private Sub BtnExit_Click()
End Sub



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Need some help with Exit Event

But be aware that the data entered into the userform is not saved, next time
it will open as designed.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Chip Pearson" wrote in message
...
Matt,

Try something like

Private Sub btnExit_Click()

Dim FName As Variant
FName = Application.GetSaveAsFilename(, "Excel Files
(*.xls),*.xls")
If FName = False Then
Exit Sub
End If
ThisWorkbook.SaveAs Filename:=FName
Me.Hide
Application.Quit
End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com




"Matt" wrote in message
oups.com...
Hi All- I've got an exit button in a user form that I want to
accomplish the following with when clicked-
1. Prompt the user to see if they want to save the form and
associated
workbook.
2. If yes to save then ask to save as and where.
3. Exit form and excel.

Presently I have the following code associated with the button.
Obviously it's inoperable at this point. I've searched quite a
bit to
find some similiar code, without much luck. Any help would be
greatly
appreciated. Thanks.

Private Sub BtnExit_Click()
End Sub





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Need some help with Exit Event

Good point Bob- Any idea of code that would allow the data to be saved
as well.

I'm also looking for a pop-up box which upon pressing the exit button
would ask the user if they wanted to save the form w/ data -- if yes
would save and if no would exit the entire application.

Thanks for everyone's help!

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Need some help with Exit Event

Matt,

You would have to hive it off somewhere, like a hidden worksheet or a text
file, and then the next time you open the form, re-in state it. All manual I
am afraid.

ans = MsgBox("Save the Form", vbYesNo)
If ans = vbYes
'call the save routine
Else
End
End If

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Matt" wrote in message
ups.com...
Good point Bob- Any idea of code that would allow the data to be saved
as well.

I'm also looking for a pop-up box which upon pressing the exit button
would ask the user if they wanted to save the form w/ data -- if yes
would save and if no would exit the entire application.

Thanks for everyone's help!



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How To Get An Event To Run When I Exit A TextBox Minitman[_4_] Excel Programming 7 October 22nd 04 11:27 PM
Form Exit Event JT[_2_] Excel Programming 1 September 17th 04 02:29 AM
combobox exit event Dave D[_3_] Excel Programming 0 April 28th 04 10:22 PM
Exit Event Michael J. Malinsky Excel Programming 1 February 27th 04 06:40 PM
Control Exit event Fred Excel Programming 0 November 19th 03 12:59 AM


All times are GMT +1. The time now is 11:18 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"