RawlinsCross
Active Member
- Joined
- Sep 9, 2016
- Messages
- 437
Good day,
I want to generate a report from various userforms I have in a workbook. My plan is to generate each userform separately and then copy and paste it to a WordEditor object in an outlook MailItem (I think). Setting up the email is fairly straight forward. I think I can manage calling each userform separately, but how do I then copy and paste each userform in turn into the email?
I want to generate a report from various userforms I have in a workbook. My plan is to generate each userform separately and then copy and paste it to a WordEditor object in an outlook MailItem (I think). Setting up the email is fairly straight forward. I think I can manage calling each userform separately, but how do I then copy and paste each userform in turn into the email?
VBA Code:
Public Sub EmailReport()
Dim ol As Outlook.Application
Dim mi As Outlook.MailItem
Dim doc As Word.Document
Dim shpHeader As Word.InlineShape
Dim shpGraph1 As Word.InlineShape
Set ol = New Outlook.Application
Set mi = ol.CreateItem(olMailItem)
mi.To = "someone@somewhere.com"
mi.Subject = "Report"
Set doc = mi.GetInspector.WordEditor
Set shpHeader = doc.Range(0, 0).InlineShapes.AddPicture(Environ("USERPROFILE") & "\Pictures\ReportHeader.gif")
Set shpGraph1 = doc.Range(1, 1).InlineShapes.AddPicture(Environ("USERPROFILE") & "\Pictures\Graph1.gif") 'I tested this here, but would want this to be a paste of a userform.
mi.Display
End Sub