Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default ActiveWorkbook.SendMail not working

i'm trying to make a file copy a single sheet to a new workbook, save
the new workbook, then email the workbook. I make it decide whether or
not to just save or save and email based on a flag mySave The save
works without problems, but when i try to save and email, i get a run
time error 1004, method 'SendMail' of object'_Workbook' failed.

here's what i have so far

If mySave = 2 Then ActiveWorkbook.SendMail myRecipients, mySubject

right now i have myRecipients = [main!b2:b3].value and mySubject =
"Subject" i've tried changing the myRecipients to just a single email
address, even changed the sendmail line to refer directly to a single
email address and subject without referencing a variable, but with
everthing i've tried, the result has always been the error 1004.
here's the whole sub, any ideas?

Sub CreateFile()
Call TurnOff
Dim myName As String
Call ParseName
Sheets(myData).Select
myName = [g1].Value
Sheets(mySheet).Select
Range("A1:K55").Select
Range("K55").Activate
Selection.Copy
Workbooks.Open Filename:="C:\SCR\Templates\VersaCold.xlt",
Editable:=True
Call TurnOff
Range("A1:K55").Select
Range("K55").Activate
Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats,
Operation:= _
xlNone, SkipBlanks:=False, Transpose:=False
Selection.PasteSpecial Paste:=xlPasteColumnWidths,
Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Selection.PasteSpecial Paste:=xlFormats, Operation:=xlNone,
SkipBlanks:=False, _
Transpose:=False
Range("H15").Select
Application.CutCopyMode = False
ActiveWorkbook.SaveAs Filename:="C:\SCR\" & myFolder & "\" & myName
& ".xls", _
FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
If mySave = 2 Then ActiveWorkbook.SendMail myRecipients, mySubject
MsgBox "File Saved"
ActiveWorkbook.Close
Windows("scr workstation.xls").Activate
Sheets("main").Activate
Call TurnOn
End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 709
Default ActiveWorkbook.SendMail not working

Craig, have a look at Ron de Bruin's site here
http://www.rondebruin.nl/sendmail.htm for LOTS of information on send mail

--
Paul B
Always backup your data before trying something new
Please post any response to the newsgroups so others can benefit from it
Feedback on answers is always appreciated!
Using Excel 2002 & 2003

"Craig" wrote in message
oups.com...
i'm trying to make a file copy a single sheet to a new workbook, save
the new workbook, then email the workbook. I make it decide whether or
not to just save or save and email based on a flag mySave The save
works without problems, but when i try to save and email, i get a run
time error 1004, method 'SendMail' of object'_Workbook' failed.

here's what i have so far

If mySave = 2 Then ActiveWorkbook.SendMail myRecipients, mySubject

right now i have myRecipients = [main!b2:b3].value and mySubject =
"Subject" i've tried changing the myRecipients to just a single email
address, even changed the sendmail line to refer directly to a single
email address and subject without referencing a variable, but with
everthing i've tried, the result has always been the error 1004.
here's the whole sub, any ideas?

Sub CreateFile()
Call TurnOff
Dim myName As String
Call ParseName
Sheets(myData).Select
myName = [g1].Value
Sheets(mySheet).Select
Range("A1:K55").Select
Range("K55").Activate
Selection.Copy
Workbooks.Open Filename:="C:\SCR\Templates\VersaCold.xlt",
Editable:=True
Call TurnOff
Range("A1:K55").Select
Range("K55").Activate
Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats,
Operation:= _
xlNone, SkipBlanks:=False, Transpose:=False
Selection.PasteSpecial Paste:=xlPasteColumnWidths,
Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Selection.PasteSpecial Paste:=xlFormats, Operation:=xlNone,
SkipBlanks:=False, _
Transpose:=False
Range("H15").Select
Application.CutCopyMode = False
ActiveWorkbook.SaveAs Filename:="C:\SCR\" & myFolder & "\" & myName
& ".xls", _
FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
If mySave = 2 Then ActiveWorkbook.SendMail myRecipients, mySubject
MsgBox "File Saved"
ActiveWorkbook.Close
Windows("scr workstation.xls").Activate
Sheets("main").Activate
Call TurnOn
End Sub



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
ActiveWorkbook.SendMail - Message body al007 Excel Programming 2 January 24th 06 02:59 PM
Alert message during Activeworkbook.sendmail N10 Excel Programming 3 April 2nd 05 01:32 PM
ActiveWorkbook.SendMail Sandy Excel Programming 2 March 15th 05 07:17 AM
ActiveWorkbook.SendMail Security Warning Michael Rekas[_2_] Excel Programming 2 December 16th 04 05:28 PM
Activeworkbook.sendmail Jamie[_5_] Excel Programming 2 October 2nd 03 01:25 PM


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

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

About Us

"It's about Microsoft Excel"