No time today to look at your problem
Party time today with 200 people( my wife 40e birthday) so no time today.
After cleaning up the mess tomorrow I will look at your problem
--
Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm
Yes I do.
Here's whats happening.
In workbook MAIN in module1 theres a sub that creates a new workbook
using a class thanks to DOUG here:
http://groups.google.com/group/micr...a/dcb3867cdc887b82?lnk=st&q=#dcb3867cdc887b82
Add new workbook and copy/paste values and formats.
This report is going to be emailed to other people and I dont want to
have the formulas or code included (among other reasons to keep the
file small).
I dont think any of that code has any bearing to the problem, but if
you feel otherwise I can post it. (its a mess).
At the end of the sub I tried to use:
Application.EnableEvents = True
Application.CommandBars.FindControl(ID:=3738).Execute
'ActiveWorkbook.EnvelopeVisible = True
On Error Resume Next
' With ActiveSheet.MailEnvelope
'.Introduction = "This is a sample worksheet."
'.Item.To = "E-Mail_Address_Here"
' .Item.Subject = "Tracker, " + ActiveSheet.Range("C2").Value
' .Item.display
' End With
As you can see I've been playing with this.
If I send an email, or if I close the sheet on the newly created
workbook then it works fine, no problems.
The problem is when the Excel close button is used on the title bar
(the button to close excel)
Unfortunately not all people are computer savy and they will click
that button to close the sheet.
What happens is that the Private Sub Workbook_BeforeClose(Cancel As
Boolean) in the THISWORKBOOK of the Main workbook is called and this
where I this problem happens.
This is the code that I have
'If Report is not open then close workbook
If ThisWorkbook.Sheets("Settings").Range("J25").Value = "NONE" Then
'MsgBox "Hello"
ActiveWorkbook.Save
ActiveWorkbook.Close SaveChanges:=False
Else
'Report is open, close sendemail and delete report workbook .
'MsgBox ActiveWorkbook.Name
Application.ScreenUpdating = True
Application.EnableEvents = True
Application.CommandBars.FindControl(ID:=3738).Execute
'ActiveWorkbook.EnvelopeVisible = False
'Workbooks(ThisWorkbook.Sheets("Settings").Range("J25").Value).EnvelopeVisible
= False
'Application.ScreenUpdating = False
'Cancel = True
'Sheets("Settings").Range("J25").Value = "NONE"
'ActiveWorkbook.Close SaveChanges:=False
'Exit Sub
End If
Do you think you can help me?
Cheers