Live-Forum - Die aktuellen Beiträge
Datum
Titel
19.04.2024 12:23:24
19.04.2024 11:45:34
Anzeige
Archiv - Navigation
1536to1540
Aktuelles Verzeichnis
Verzeichnis Index
Übersicht Verzeichnisse
Vorheriger Thread
Rückwärts Blättern
Nächster Thread
Vorwärts blättern
Anzeige
HERBERS
Excel-Forum (Archiv)
20+ Jahre Excel-Kompetenz: Von Anwendern, für Anwender
Inhaltsverzeichnis

Range per Outlook versenden

Range per Outlook versenden
24.01.2017 10:16:22
Raimund
Hi All.
Habe folgendes Script zum versenden eines Bereiches per Outlook.
Benuzte Office 2016.
Es funktioniert alles gut bis auf Design der Pivot Tabelle, welches nicht uebernommen wird.
Hoffe, dass jemand eine Idee hat, warum es nicht funktioniert.
Danke im Voraus.
Raimund
Option Explicit
Sub Mail_Selection_Range_Outlook_Body()
Dim rng As Range
Dim OutApp As Object
Dim OutMail As Object
Dim tm, dt
tm = Format(Time, "Short Time")
dt = Format(Date, "Short Date")
Dim lngLetzte As Long
Range("B2").Select
lngLetzte = IIf(IsEmpty(Cells(Rows.Count, 6)), Cells(Rows.Count, 6).End(xlUp).Row, Rows. _
Count)
Set rng = Nothing
On Error Resume Next
Set rng = Range("A1:H" & lngLetzte)
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")
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
With OutMail
.GetInspector
If ActiveCell.Value = "Tinahely" Then
.To = ""
.Cc = ""
End If
.Subject = "Collection report: " & " " & Range("A1") & " - " & ActiveCell()
If tm " & "" & "Good Morning " & "
" & "
" & " _ Attached you will find your requested Report for " & Range("A1") & "." & "
" & "
" & "Thank you." & RangetoHTML(rng) & vbCrLf & .HTMLBody End If If tm > "12:00" Then '.HTMLBody = RangetoHTML(rng) & vbCrLf & .HTMLBody .HTMLBody = "" & "" & "Good Afternoon " & "
" & "
" & " _ Attached you will find your requested Report for " & Range("A1") & "." & "
" & "
" & "Thank you." & RangetoHTML(rng) & vbCrLf & .HTMLBody End If .Display '.Send '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

2
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Datum
Anwender
Anzeige
AW: Range per Outlook versenden
25.01.2017 08:50:41
fcs
Hallo Raimund,
wahrscheinlich kann die von dir verwendetet Function "RangetoHTML" die speziellen Formatierungen eines Pivot-Tabellenbereichts nicht erkennen/auswerten.
Hilfe bzgl. HTML kann ich ich nicht anbieten.
Evtl. solltest du den Tabellenbereich als PDF-datei exportieren und den Bericht als PDF-Datei an die E-Mail anhängen.
LG
Franz
AW: Range per Outlook versenden
25.01.2017 12:44:03
Raimund
Hi Franz.
Viellen Dank fuer Deine Antwort.
Habe es wie folgt geandert.
Funktioniert sehr gut. Problem ist, dass ich im Body Text als Times New Roman habe.
Das wuerde ich gerne im Arial bevorzugen.
Eine Idee wie ich das hier aendern kann?
Vielen Dank im Voraus
Gruss Raimund
Sub Send_Selection()
Dim Sendrng As Range
Dim tm, dt
tm = Format(Time, "Short Time")
dt = Format(Date, "Short Date")
On Error GoTo StopMacro
Range("B2").Select
With Application
.ScreenUpdating = False
.EnableEvents = Fasle
End With
Set Sendrng = Selection
With Sendrng
ActiveWorkbook.EnvelopeVisible = True
With .Parent.MailEnvelope
If tm  "12:00" Then
.Introduction = "Good Afternoon." & Chr(10) & Chr(10) & "Attached you  _
will find your Customer report." & Chr(10) & Chr(10) & "Thank you."
End If
With .Item
If ActiveCell.Value = "Tinahely" Then
.to = "raimund@xxx.ie" ' & ";" & ""
'.CC = "" & ";" & ""
End If
'.to = ""
'.CC = ""
'.BCC = ""
'.Subject = "Commercial Collection Report" & " - " & ActiveCell() & " in " &  _
Format(DateAdd("m", -1, Now), "MMMM-YYYY")
.Subject = "Commercial Collection Report" & " - " & ActiveCell() & " in " &  _
Range("A2")
'.Send
.Display
End With
End With
End With
StopMacro:
With Application
.ScreenUpdating = True
.EnableEvents = True
End With
ActiveWorkbook.EnvelopeVisible = True
End Sub

Anzeige

299 Forumthreads zu ähnlichen Themen

Anzeige
Anzeige
Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige