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
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