Cannot VBA to copy multiple ranges to multiple users.

chaichatp

New Member
Joined
May 8, 2014
Messages
22
Here is an example of 2 recipients, anything wrong?

Sub Employee_ALL()

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 = Range("D2").Text
.CC = ""
.BCC = ""
.Subject = "Fingerscan Report"
.Body = "Any questions, please feel free to ask me. Ming"
.display

Set xInspect = newEmail.GetInspector
Set pageEditor = xInspect.WordEditor

Range("B3:I54").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


Set outlook = CreateObject("Outlook.Application")
Set newEmail = outlook.CreateItem(0)

With newEmail
.To = Range("M2").Text
.CC = ""
.BCC = ""
.Subject = "Fingerscan Report"
.Body = "Any questions, please feel free to ask me. Ming"
.display

Set xInspect = newEmail.GetInspector
Set pageEditor = xInspect.WordEditor

Range("K3:R54").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
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
what do you mean by:
anything wrong?
are you expecting people to run your code for you and test whether there are any errors? if there is something wrong with it, what exactly is the issue?
 
Upvote 0

Forum statistics

Threads
1,215,646
Messages
6,125,997
Members
449,279
Latest member
Faraz5023

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top