User form and send mail

W

wizard5353

Hi guys, I'm having some problems with Ron de Bruins send mail script o
a form command. I think I know where the problem is but I can’t fix it


What I’m looking for is

1 Command button clicked
2 Current form to be emailed
3 Form data to be cleared
4 Form to be saved and then closed

It’s number two which is causing the problems. I’m using the followin
code;


Code
-------------------
Private Sub cmdemail_Click()
If MsgBox("Please note this you only be sent at the end of the day. Are you sure you have finished for the day?", vbYesNo Or vbQuestion _
Or vbDefaultButton2) = vbYes Then
Unload Me
Call Mail_workbook_Outlook
End If
End Su
-------------------



Code
-------------------
Sub Mail_workbook_Outlook()
Dim wb1 As Workbook
Dim wb2 As Workbook
Dim wbname As String
Application.ScreenUpdating = False
Set wb1 = ActiveWorkbook
wbname = "H:/" & wb1.Name & " " & _
Format(Now, "dd-mm-yy h-mm-ss") & ".xls"
wb1.SaveCopyAs wbname
Set wb2 = Workbooks.Open(wbname)
With wb2
.SendMail "(e-mail address removed)", _
"todays work"
.ChangeFileAccess xlReadOnly
Kill .FullName
.Close False
End With
Application.ScreenUpdating = True
End Su
-------------------


The program just hangs at the save temporary file part until you clic
on the close cross on the form so it looks like it will not save unles
the form is closed but my efforts with Unload Me or Unload (Formname
have been in vain.

Could anyone give me some pointers to where I have gone wrong?

-N
 
R

Ron de Bruin

Hi wizard5353

I test it and it is working for me.
You can send me your test workbook private then I test it for you.
 

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

Top