Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Help with Syntax in Code

..From = ThisWorkbook.Sheets(1).Range("F27").Value

should work if the address is in the workbook containing the code on the
first sheet in range F27. What's the problem?

--
Regards,
Tom Ogilvy


"Ken Hudson" wrote:

I found the code string below a while back and don't remember the author. My
apologies for the lack of acknowledgement. This code sends workbooks to users
through Outlook. It works fine, but I wanted to customize it slightly. In the
line of code that begins with ".From" I want to enter a cell reference in a
workbook rather than have the sender's name hard coded. I tried:

.From = ThisWorkbook.Sheets(1).Range("F27").Value

and a couple of other variations, but can't get it to accept this cell
reference.

Anyone have the solution?
TIA.

-------------------------

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
Application.DisplayAlerts = False

Set iConf = CreateObject("CDO.Configuration")
iConf.Load -1 ' CDO Source Defaults
Set Flds = iConf.Fields
With Flds
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") =
"SMTP.va.gov"
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") =
25
.Update
End With

For Each ws In ActiveWorkbook.Worksheets
If ws.Range("A3").Value Like "?*@?*.?*" Then
ws.Copy
Set wb = ActiveWorkbook
WBname = "C:/Personal/" & ws.Name & ".xls"
wb.SaveAs WBname
wb.Close False
Set wb = Nothing

Set iMsg = CreateObject("CDO.Message")
With iMsg
Set .Configuration = iConf
.To = ws.Range("A3").Value
.CC = ThisWorkbook.Sheets(1).Range("F27").Value
.From = """Ken Hudson"" "
.Subject = "FCP User Validation for " & ws.Name
.AddAttachment WBname
.TextBody = ThisWorkbook.Sheets(1).Range("A30")
.Send
End With
Set iMsg = Nothing
Kill WBname
End If
Next ws

Set iConf = Nothing
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub


--
Ken Hudson

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
Syntax problem with code WLMPilot Excel Discussion (Misc queries) 1 March 15th 08 07:07 PM
Syntax of VBA Code Ken Hudson Excel Programming 1 September 14th 05 10:09 PM
Syntax of this code ExcelMonkey Excel Programming 1 July 21st 05 11:29 AM
syntax for code in MsgBox()? Ouka[_4_] Excel Programming 2 July 20th 05 05:18 PM
help with code/syntax Jay Baxter Excel Programming 0 February 26th 04 08:11 PM


All times are GMT +1. The time now is 04:02 PM.

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"