Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Problem with .sendmail

Hi all,

I am creating a spreadsheet that is sent out to individuals, they fill in
details and then using a "submit" button, return it to me.

I am using code I got from Ron DeBruin's site but unfortunately I cannot get
it to work. Excel gets to the point of sending the email and then just
freezes. When I run this from VBA explorer it works ok and the dialog box
saying Excel is trying to send an email appears and the email is sent when I
press yes. The problem is that it won't work if VBA is not open. Any ideas?
The send code is below.

'Save the new workbook/Mail it/Delete it

'TempFilePath = Environ$("temp") & "\"
TempFilePath = Dir

'TempFileName = "Part of " & Sourcewb.Name & " " & Format(Now,
"dd-mmm-yy h-mm-ss")
TempFileName = Filename & " Returned" & ".xls"

MsgBox "Your form is being returned"

With Destwb
.SaveAs TempFilePath & TempFileName, FileFormat:=FileFormatNum

MsgBox "Saved Temp File"
On Error Resume Next
MsgBox "About to send"

.SendMail ", _
TempFileName
'On Error GoTo 0
MsgBox "Sent"
.Close SaveChanges:=False
End With

'Delete the file you have send
Kill TempFilePath & TempFileName

With Application
.ScreenUpdating = True
.EnableEvents = True
End With
End Sub

Alternative code that I have used in the past is a s follows:

Dim Mail As String
Let Mail = "

' Application.Dialogs(xlDialogSendMail).Show arg1:=Mail


This works but the sendmail option seemed slightly more elegant (and also
removed most opportunities for users to mess up the process.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Problem with .sendmail

Hi Joseph

If you run the code from a controltoolbox button you can add this line in
the macro (as first line)

Activecell.Select

Or you can change the takefocusonclick in the button properties

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Joseph Fletcher" wrote in message
...
Hi all,

I am creating a spreadsheet that is sent out to individuals, they fill in
details and then using a "submit" button, return it to me.

I am using code I got from Ron DeBruin's site but unfortunately I cannot get
it to work. Excel gets to the point of sending the email and then just
freezes. When I run this from VBA explorer it works ok and the dialog box
saying Excel is trying to send an email appears and the email is sent when I
press yes. The problem is that it won't work if VBA is not open. Any ideas?
The send code is below.

'Save the new workbook/Mail it/Delete it

'TempFilePath = Environ$("temp") & "\"
TempFilePath = Dir

'TempFileName = "Part of " & Sourcewb.Name & " " & Format(Now,
"dd-mmm-yy h-mm-ss")
TempFileName = Filename & " Returned" & ".xls"

MsgBox "Your form is being returned"

With Destwb
.SaveAs TempFilePath & TempFileName, FileFormat:=FileFormatNum

MsgBox "Saved Temp File"
On Error Resume Next
MsgBox "About to send"

.SendMail ", _
TempFileName
'On Error GoTo 0
MsgBox "Sent"
.Close SaveChanges:=False
End With

'Delete the file you have send
Kill TempFilePath & TempFileName

With Application
.ScreenUpdating = True
.EnableEvents = True
End With
End Sub

Alternative code that I have used in the past is a s follows:

Dim Mail As String
Let Mail = "

' Application.Dialogs(xlDialogSendMail).Show arg1:=Mail


This works but the sendmail option seemed slightly more elegant (and also
removed most opportunities for users to mess up the process.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Problem with .sendmail

Sorry Ron, I tried both of these suggestions but neither worked. I have
Msgboxes either side of the command, one saying that it is about ot send and
one saying that it has been sent, the first one appears and then excel stops
responding, I assume as it is trying to send the mail.

"Ron de Bruin" wrote:

Hi Joseph

If you run the code from a controltoolbox button you can add this line in
the macro (as first line)

Activecell.Select

Or you can change the takefocusonclick in the button properties

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Joseph Fletcher" wrote in message
...
Hi all,

I am creating a spreadsheet that is sent out to individuals, they fill in
details and then using a "submit" button, return it to me.

I am using code I got from Ron DeBruin's site but unfortunately I cannot get
it to work. Excel gets to the point of sending the email and then just
freezes. When I run this from VBA explorer it works ok and the dialog box
saying Excel is trying to send an email appears and the email is sent when I
press yes. The problem is that it won't work if VBA is not open. Any ideas?
The send code is below.

'Save the new workbook/Mail it/Delete it

'TempFilePath = Environ$("temp") & "\"
TempFilePath = Dir

'TempFileName = "Part of " & Sourcewb.Name & " " & Format(Now,
"dd-mmm-yy h-mm-ss")
TempFileName = Filename & " Returned" & ".xls"

MsgBox "Your form is being returned"

With Destwb
.SaveAs TempFilePath & TempFileName, FileFormat:=FileFormatNum

MsgBox "Saved Temp File"
On Error Resume Next
MsgBox "About to send"

.SendMail ", _
TempFileName
'On Error GoTo 0
MsgBox "Sent"
.Close SaveChanges:=False
End With

'Delete the file you have send
Kill TempFilePath & TempFileName

With Application
.ScreenUpdating = True
.EnableEvents = True
End With
End Sub

Alternative code that I have used in the past is a s follows:

Dim Mail As String
Let Mail = "

' Application.Dialogs(xlDialogSendMail).Show arg1:=Mail


This works but the sendmail option seemed slightly more elegant (and also
removed most opportunities for users to mess up the process.



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Problem with .sendmail

Hi Joseph

If you use the example workbook on my site do you have the same problem then
http://www.rondebruin.nl/sendmail.htm

Download the first file (red link) en test the examples



--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Joseph Fletcher" wrote in message
...
Sorry Ron, I tried both of these suggestions but neither worked. I have
Msgboxes either side of the command, one saying that it is about ot send and
one saying that it has been sent, the first one appears and then excel stops
responding, I assume as it is trying to send the mail.

"Ron de Bruin" wrote:

Hi Joseph

If you run the code from a controltoolbox button you can add this line in
the macro (as first line)

Activecell.Select

Or you can change the takefocusonclick in the button properties

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Joseph Fletcher" wrote in message
...
Hi all,

I am creating a spreadsheet that is sent out to individuals, they fill in
details and then using a "submit" button, return it to me.

I am using code I got from Ron DeBruin's site but unfortunately I cannot get
it to work. Excel gets to the point of sending the email and then just
freezes. When I run this from VBA explorer it works ok and the dialog box
saying Excel is trying to send an email appears and the email is sent when I
press yes. The problem is that it won't work if VBA is not open. Any ideas?
The send code is below.

'Save the new workbook/Mail it/Delete it

'TempFilePath = Environ$("temp") & "\"
TempFilePath = Dir

'TempFileName = "Part of " & Sourcewb.Name & " " & Format(Now,
"dd-mmm-yy h-mm-ss")
TempFileName = Filename & " Returned" & ".xls"

MsgBox "Your form is being returned"

With Destwb
.SaveAs TempFilePath & TempFileName, FileFormat:=FileFormatNum

MsgBox "Saved Temp File"
On Error Resume Next
MsgBox "About to send"

.SendMail ", _
TempFileName
'On Error GoTo 0
MsgBox "Sent"
.Close SaveChanges:=False
End With

'Delete the file you have send
Kill TempFilePath & TempFileName

With Application
.ScreenUpdating = True
.EnableEvents = True
End With
End Sub

Alternative code that I have used in the past is a s follows:

Dim Mail As String
Let Mail = "

' Application.Dialogs(xlDialogSendMail).Show arg1:=Mail


This works but the sendmail option seemed slightly more elegant (and also
removed most opportunities for users to mess up the process.




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
sendmail macro problem in Excel vic1 Setting up and Configuration of Excel 10 May 28th 08 11:35 AM
Need Help with SendMail AccessHelp Excel Programming 6 November 26th 05 08:54 AM
SendMail N_R_M Excel Programming 0 November 21st 05 04:40 PM
Sendmail rbaxter[_7_] Excel Programming 1 September 15th 04 04:24 PM
Sendmail: Problem when used after a Userform Bernard Foot Excel Programming 12 July 2nd 04 03:49 PM


All times are GMT +1. The time now is 11:15 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"