ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   form_unload problem (https://www.excelbanter.com/excel-programming/333797-form_unload-problem.html)

Benny5788

form_unload problem
 

Hi, I have never done any macros in vba for excel. I have however don
some vb, but it was a long time ago. If i remember well Private Su
Form_Unload(Cancel As Integer) was everything u wanted to do before
closed ur form. Heres the beginning of the code i was working on.
Nothing happens on the form unload, i tryed putting a messagebox there
but nothing happened. Is there something u gotta do differently in vb
then in vb

Thanks
Ben

Option Explicit

Private Sub Form_Load()

End Sub

Private Sub Form_Unload(Cancel As Integer)

If ThisWorkbook.Saved = False Then
ThisWorkbook.Save
End If

ThisWorkbook.Close

End Su

--
Benny578
-----------------------------------------------------------------------
Benny5788's Profile: http://www.excelforum.com/member.php...fo&userid=2497
View this thread: http://www.excelforum.com/showthread.php?threadid=38502


Norie

form_unload problem
 

As far as I know there is no Unload event for a userform in VBA.

There are Terminate, Deactivate and QueryClose events

--
Nori
-----------------------------------------------------------------------
Norie's Profile: http://www.excelforum.com/member.php...fo&userid=1936
View this thread: http://www.excelforum.com/showthread.php?threadid=38502


Bob Phillips[_7_]

form_unload problem
 
You want the Userform_Terminate event.

--
HTH

Bob Phillips

"Benny5788" wrote
in message ...

Hi, I have never done any macros in vba for excel. I have however done
some vb, but it was a long time ago. If i remember well Private Sub
Form_Unload(Cancel As Integer) was everything u wanted to do before u
closed ur form. Heres the beginning of the code i was working on.
Nothing happens on the form unload, i tryed putting a messagebox there,
but nothing happened. Is there something u gotta do differently in vba
then in vb

Thanks
Ben

Option Explicit

Private Sub Form_Load()

End Sub

Private Sub Form_Unload(Cancel As Integer)

If ThisWorkbook.Saved = False Then
ThisWorkbook.Save
End If

ThisWorkbook.Close

End Sub


--
Benny5788
------------------------------------------------------------------------
Benny5788's Profile:

http://www.excelforum.com/member.php...o&userid=24975
View this thread: http://www.excelforum.com/showthread...hreadid=385024





All times are GMT +1. The time now is 04:54 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com