View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Jim Cone Jim Cone is offline
external usenet poster
 
Posts: 3,290
Default Help with Calling a subroutine in the ThisWorkbook Class


Instead of... Call Workbook_BeforeClose(True)
Use... ThisWorkbook.Close
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)


"freshforlife"
wrote in message
Hi All,
I have defined a subroutine in the ThisWorkbook class as:

Private Sub Workbook_BeforeClose(Cancel As Boolean)
--- code
--- code
End Sub

Now I have another subroutine in Module 1 of my workbook:

Sub Userform()
-- Code
-- Code
If Err = 0 Then
Call Workbook_BeforeClose(True)
Exit Sub
End If
End Sub


Now I want to call the subroutine Workbook_BeforeClose from within the
Userform() routine, if there is an Error is encountered -- basically i
want to close the entire workbook.
Can somebody shed light on how to achieve this ?
Thanks,
Ravi