I have this simple macro that needs to take specific tabs (dynamic), copy and send them in an email - But it keeps taking my reference mail from A1 in the paste - Someone who can see the fail or lead me in the right direction?
Note that the answer is not to put the reference mail in another tab as in the real excel sheet there needs to information above the copied.
code
Sub esendtable()
Dim outlook As Object
Dim newEmail As Object
Dim xInspect As Object
Dim pageEditor As Object
Set outlook = CreateObject("Outlook.Application")
Set newEmail = outlook.CreateItem(0)
With newEmail
.To = Sheet1.Range("A1").Text
.CC = ""
.BCC = ""
.Subject = "Personoplysninger"
.Body = "Jvf. aftale er her oplysninger" & vbCrLf & "Venlig hilsen Kim"
.display
Set xInspect = newEmail.GetInspector
Set pageEditor = xInspect.WordEditor
'Sheet1.Range("B2:E5").Copy
Sheet1.Range("A2").CurrentRegion.Copy
pageEditor.Application.Selection.Start = Len(.Body)
pageEditor.Application.Selection.End = pageEditor.Application.Selection.Start
pageEditor.Application.Selection.PasteAndFormat (wdFormatPlainText)
.display
'.Send
Set pageEditor = Nothing
Set xInspect = Nothing
End With
Set newEmail = Nothing
Set outlook = Nothing
End Sub
Bookmarks