Hi,
when I run this program, i get Run time Error 9. at first "set wsM"
am i doing something wrong?
when i change this to .activeworksheet, error dissapears.
this error is same across all the set functions.
please help.
when I run this program, i get Run time Error 9. at first "set wsM"
am i doing something wrong?
when i change this to .activeworksheet, error dissapears.
this error is same across all the set functions.
please help.
VBA Code:
Sub Test()
Dim OutApp As Object
Dim OutMail As Object
Dim strbody As String
Dim Signature As String
Dim wbMain As Workbook
Dim wsM As Worksheet
Dim wsQ As Worksheet
Dim wsB As Worksheet
Dim Email_Subject As String
Set wbMain = ThisWorkbook
wbMain.Activate
Set wsM = wbMain.Worksheets("Sheet2")
Email_Subject = wsM.Range("H2").Value & " Acceptance"
' Set wsQ = wbMain.Worksheets("Sheet4")
' Set wsB = wbMain.Worksheets("Sheet9")
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
strbody = "<html>" & _
"<style>" & "table,th,td" & "{border: 1px solid black ; border-collapse: collapse}" & "</style>" & _
"<table style=" & "width:50%" & ">" & _
"<tr>" & "<td>" & Range("A1") & "</td>" & "<td>" & Range("B1") & "</td>" & "<td>" & Range("C1") & "</td>" & "</tr>" & _
"<tr>" & "<td>" & Range("A2") & "</td>" & "<td>" & Range("B2") & "</td>" & "<td>" & Range("C2") & "</td>" & "</tr>" & _
"<tr>" & "<td>" & Range("A3") & "</td>" & "<td>" & Range("B3") & "</td>" & "<td>" & Range("C3") & "</td>" & "</tr>" & _
"<tr>" & "<td>" & Range("A4") & "</td>" & "<td>" & Range("B4") & "</td>" & "<td>" & Range("C4") & "</td>" & "</tr>" & "</table>" & "</html>"
With OutMail
.To = "[EMAIL]zzz.com@zzz.com[/EMAIL]"
.CC = ""
.BCC = ""
.Subject = Email_Subject
.HTMLBody = strbody
.Display (True)
End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
End Sub
Last edited by a moderator: