using rons email but need just printrange to mail

  • Thread starter Thread starter pswanie
  • Start date Start date
P

pswanie

im using one of rons email macro's to mail the sheet.
i got my checkbox linked to k4. outside of the print range (when u go
printpreview)

but when i email it in the body of mail as html it includes all the data
even if i got it in white so it does not show on screen.
 
Hi

Try this
Set rng = Range(ActiveSheet.PageSetup.PrintArea)


Sub Mail_Selection_Range_Outlook_Body()
' Don't forget to copy the function RangetoHTML in the module.
' Working in Office 2000-2007
Dim rng As Range
Dim OutApp As Object
Dim OutMail As Object

Set rng = Nothing
On Error Resume Next
Set rng = Range(ActiveSheet.PageSetup.PrintArea)
On Error GoTo 0

If rng Is Nothing Then
MsgBox "The selection is not a range or the sheet is protected" & _
vbNewLine & "please correct and try again.", vbOKOnly
Exit Sub
End If

With Application
.EnableEvents = False
.ScreenUpdating = False
End With

Set OutApp = CreateObject("Outlook.Application")
OutApp.Session.Logon
Set OutMail = OutApp.CreateItem(0)

On Error Resume Next
With OutMail
.To = "(e-mail address removed)"
.CC = ""
.BCC = ""
.Subject = "This is the Subject line"
.HTMLBody = RangetoHTML(rng)
.display 'or use .Display
End With
On Error GoTo 0

With Application
.EnableEvents = True
.ScreenUpdating = True
End With

Set OutMail = Nothing
Set OutApp = Nothing
End Sub
 
just that one line that i need to add in and then ive " ' " the old line?

im getting a error
 
Sub Mail_Sheet_Outlook_Body()
' Don't forget to copy the function RangetoHTML in the module.
'thanx to Ron 4 this macro
' Working in Office 2000-2007
Dim rng As Range
Dim OutApp As Object
Dim OutMail As Object
With Application
.EnableEvents = False
.ScreenUpdating = False
End With

Set rng = Nothing
'Set rng = ActiveSheet.UsedRange
'You can also use a sheet name
'Set rng = Sheets("sheet1").UsedRange
Set rng = Range(ActiveSheet.PageSetup.PrintArea)



Set OutApp = CreateObject("Outlook.Application")
OutApp.Session.Logon
Set OutMail = OutApp.CreateItem(0)

On Error Resume Next
With OutMail
.to = "(e-mail address removed)"
'.CC = ""
'.BCC = ""
.Subject = "Fault description log sent:" & " " & Format(Date, "dddd
dd/mm/yyyy") & " " & Format(Now, "hh:mm")
.HTMLBody = RangetoHTML(rng)
.Send 'or use .Display
End With
On Error GoTo 0

With Application
.EnableEvents = True
.ScreenUpdating = True
End With

Set OutMail = Nothing
Set OutApp = Nothing

Sheets("Sheet1").PrintOut



End Sub
 
i do get the msg box. but i do have data on the sheet that needs to mail.


my data is from a1 to j37 on sheet1

got other data on sheet2 aswell

will check again tomorow and let u know....
time to go home
 
Do you have set the print area manual ?

When you do Ctrl F3 you can see if there is a named range Print_Area.
If not set it and try the code again
 
thanx ron...

did not know about the ctrl f3.... learn something new every day.. will
keep that in mind next time
 
Back
Top