trying to get out

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Have a befor close save event works fine want to if possible have a userform
show while save is going on then close workbook ie excel Tried this no go
also tried an option button on userform no go.
Would like userform7 to show while save is goung on them shut down. Hope I
made this understandable.
Thanks to all

Private Sub Workbook_BeforeClose(cancel As Boolean)
UserForm7.Show
' ThisWorkbook.Save
'UserForm7.Show
End Sub
 
Curt,

You need to show the form as non-modal.. Give this a try:


Private Sub Workbook_BeforeClose(Cancel As Boolean)

UserForm7.Show False
DoEvents
ThisWorkbook.Save

End Sub
 
False made the userform lose all graphics nothing but a blank whits screen.
Save worked as should. Maybe the close button on excel could trigger the form
and use the form to save and close. have never used the close x to do
something like this.
Do have the userform option button so will save and close. Am trying to have
this be seen while program closes
Thanks
 
The call to DoEvents should have painted the user form before initiating the
workbook save...

Another way might be to show the user form as non modal, wait for 1 or 2
seconds. then execute the save and finally close the workbook. Try something
like this in the ThisWorkbook code module.

Private bProgramClosing As Boolean

Private Sub Workbook_BeforeClose(Cancel As Boolean)
If Not bProgramClosing Then
UserForm7.Show False
Application.OnTime Now + TimeValue("00:00:2"),
"ThisWorkbook.CloseWorkBook"
Cancel = True
End If
End Sub

Sub CloseWorkBook()
ThisWorkbook.Save
bProgramClosing = True
Me.Close
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top