LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Problem with macro to email file using CDO


Dear all, I have taken some code I found on Ron DeBruins website, but
when I run it it flashes up "object required".
Any suggestions as to why this happens ?
FYI I am running the macro from a network location.
The to, from and subject lines are based on the values in A1, A2 and
A3.
Thanks in advance
Amy xx

Sub CDO_Mail_Every_Worksheet_File()
Dim iMsg As Object
Dim iConf As Object
Dim ws As Worksheet
Dim wb As Workbook
Dim WBname As String
' Dim Flds As Variant
Application.ScreenUpdating = False

For Each ws In ThisWorkbook.Worksheets
If ws.Range("a1").Value Like "?*@?*.?*" Then
ws.Copy
Set wb = ActiveWorkbook
'' ChDir "S:\Files\temporary folder"
WBname = "S:\Files\temporary folder\ " & ws.Name & ".xls"
wb.SaveAs WBname
wb.Close False
Set wb = Nothing
Set iMsg = CreateObject("CDO.Message", "S:\scott\temporary
folder\" & ws.Name & ".xls")
With iMsg
Set .Configuration = iConf
..To = ws.Range("a1").Value
..From = s.Range("a2").Value
..Subject = "Sheet: " & ws.Name
..AddAttachment WBname
..TextBody = ws.Range("a3").Value
..Fields("urn:schemas:mailheader:X-Priority") = 1
..Send
End With
Set iMsg = Nothing
Kill WBname
End If
Next ws

Set iConf = Nothing
Application.ScreenUpdating = True
End Sub


--
AmyTaylor
------------------------------------------------------------------------
AmyTaylor's Profile: http://www.excelforum.com/member.php...o&userid=20970
View this thread: http://www.excelforum.com/showthread...hreadid=519648

 
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
How do I use macro in Excel 2007 to convert to and email PDF file rick5555 Excel Worksheet Functions 9 November 15th 13 04:39 PM
Problem with macro to email xls hnyb1 Excel Discussion (Misc queries) 5 June 19th 07 09:41 PM
Email from macro problem Peter[_28_] Excel Programming 3 April 10th 05 11:55 PM
Save a file and send as an email - written into macro Louise Semaj Excel Programming 1 October 22nd 03 02:19 AM
Add shortcut instead of file to Email with Macro Richard Pieri Excel Programming 1 July 30th 03 04:15 PM


All times are GMT +1. The time now is 09:30 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"