Dear Forum,
I have this code in Excel VBA:
Sub Outlook_Mail_Every_Worksheet_Body()
Dim OutApp As Object
Dim OutMail As Object
Dim ws As Worksheet
With Application
.EnableEvents = False
.ScreenUpdating = False
End With
Set OutApp = CreateObject("Outlook.Application")
For Each ws In ActiveWorkbook.Worksheets
If ws.Range("I1").Value Like "?*@?*.?*" And ws.Range("I3").Value <> 0 Then
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
With OutMail
.To = ws.Range("I1").Value
.CC = ws.Range("I2").Value
.Subject = ws.Range("A1").Value
.HTMLBody = RangetoHTML(ws.UsedRange)
'You can add a file like this
'.Attachments.Add ("C:\test.txt")
.Send 'or use .Display
End With
On Error GoTo 0
Set OutMail = Nothing
End If
Next ws
Set OutApp = Nothing
With Application
.EnableEvents = True
.ScreenUpdating = True
End With
End Sub
I am trying to incorporate the following code into it: " Set rng = ActiveSheet.UsedRange.SpecialCells(xlCellTypeVisible) " in order to hide a row for the recipients. It will not work however - I would highly appreciate any help on this matter!
Thank you,
Victor
I have this code in Excel VBA:
Sub Outlook_Mail_Every_Worksheet_Body()
Dim OutApp As Object
Dim OutMail As Object
Dim ws As Worksheet
With Application
.EnableEvents = False
.ScreenUpdating = False
End With
Set OutApp = CreateObject("Outlook.Application")
For Each ws In ActiveWorkbook.Worksheets
If ws.Range("I1").Value Like "?*@?*.?*" And ws.Range("I3").Value <> 0 Then
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
With OutMail
.To = ws.Range("I1").Value
.CC = ws.Range("I2").Value
.Subject = ws.Range("A1").Value
.HTMLBody = RangetoHTML(ws.UsedRange)
'You can add a file like this
'.Attachments.Add ("C:\test.txt")
.Send 'or use .Display
End With
On Error GoTo 0
Set OutMail = Nothing
End If
Next ws
Set OutApp = Nothing
With Application
.EnableEvents = True
.ScreenUpdating = True
End With
End Sub
I am trying to incorporate the following code into it: " Set rng = ActiveSheet.UsedRange.SpecialCells(xlCellTypeVisible) " in order to hide a row for the recipients. It will not work however - I would highly appreciate any help on this matter!
Thank you,
Victor