Defining the subject of an Email by value in range

R

RPIJG

Is this possible? I'm using this from Ron...


Code
-------------------
Dim strDate As String
Sheets("Quote").Copy
strDate = Format(Date, "dd-mm-yy")
ActiveWorkbook.SaveAs "Your Synthetic Shield " & ThisWorkbook.Name _
& " " & strDate & ".xls"
ActiveWorkbook.SendMail "", _
"This is the Subject line"
ActiveWorkbook.ChangeFileAccess xlReadOnly
Kill ActiveWorkbook.FullName
ActiveWorkbook.Close Fals
 
R

RPIJG

Ok, so now I'm using


Code
-------------------
Dim OutApp As Outlook.Application
Dim OutMail As Outlook.MailItem
Dim wb As Workbook
Dim strdate As String
strdate = Format(Now, "dd-mm-yy ")
Application.ScreenUpdating = False
Sheets("Quote").Copy
Set wb = ActiveWorkbook
With wb
.SaveAs "Quote " & ThisWorkbook.Name _
& " " & strdate & ".xls"
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(olMailItem)
With OutMail
.To = ""
.CC = ""
.BCC = ""
.Subject = "Your Synthetic Shield Invoice for your " + Sheets("Quote").Range("E47").Text + Sheets("Quote").Range("E49").Text + Sheets("Quote").Range("E51").Text
.Body = "Here is your Synthetic Shield Invoice as you requested. Thanks Again for your service."
.Attachments.Add wb.FullName
'You can add other files also like this
'.Attachments.Add ("C:\test.txt")
.Display
End With
.ChangeFileAccess xlReadOnly
Kill .FullName
End With
Application.ScreenUpdating = True
Set OutMail = Nothing
Set OutApp = Nothin
-------------------


and I'm recieving an error at the DimApp line (the first line),
checked to make sure I had made the reference and it was there? wher
have I gone wrong
 
D

Dick Kusleika

RPIJG

What is the error you are getting? Check the references again. Make sure
there is a check next to Microsoft Outlook x.0 Object Library. Just
selecting the entry doesn't set the reference, you have to put a check by
it. Also, don't confuse it with Microsoft Office x.0 Object Library.

--
Dick Kusleika
MVP - Excel
Excel Blog - Daily Dose of Excel
www.dicks-blog.com

RPIJG > said:
Ok, so now I'm using


Code:
--------------------
Dim OutApp As Outlook.Application
Dim OutMail As Outlook.MailItem
Dim wb As Workbook
Dim strdate As String
strdate = Format(Now, "dd-mm-yy ")
Application.ScreenUpdating = False
Sheets("Quote").Copy
Set wb = ActiveWorkbook
With wb
.SaveAs "Quote " & ThisWorkbook.Name _
& " " & strdate & ".xls"
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(olMailItem)
With OutMail
.To = ""
.CC = ""
.BCC = ""
.Subject = "Your Synthetic Shield Invoice for your " +
Sheets("Quote").Range("E47").Text + Sheets("Quote").Range("E49").Text +
Sheets("Quote").Range("E51").Text
 
R

Ron de Bruin

.Subject = "Your Synthetic Shield Invoice for your " + Sheets("Quote").Range("E47").Text + Sheets("Quote").Range>("E49").Text +
Sheets("Quote").Range("E51").Text

Instead of + use &
 
R

RPIJG

Yeah I didn't set the reference right...and I used the & instead of + i
works great now, thanks everyone for all of your help
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top