File Name for E-mailed workbook
Posted by Lewis (1) on December 24, 2001 4:33 AM
Hi
I am using the following to E-mail a sheet from a workbook. The attached file is given the default name Book1 etc.
Dim myFile As String, s As String
ThisWorkbook.ActiveSheet.Copy
myFile = ActiveWorkbook.Name
ThisWorkbook.Activate
If Not IsNull(Application.MailSession) Then Application.MailLogon
With ThisWorkbook.Worksheets("Sheet6").Cells
For Each c In .Range("D2:D12").Cells
s = c.Value
If s = "" Then GoTo Skip
Workbooks(myFile).SendMail Recipients:=s, _
Subject:="Here is a NEW Problem Report", _
ReturnReceipt:=False
Skip:
Next c
End With
Workbooks(myFile).Close savechanges:=False
I am trying to get it to use a value from a cell in the workbook for the file name.
I have tried putting
myFile = Range("B5").Value
in at various points without sucess. The value in B5 is numeric.
Any suggestions??
Lewis