Hi,
Basically I'm trying to create a form in excel which can be filled in by the user, the content of the form isn't an issue and I am able to tell my macro to paste the excel data into a word document but now I want the same macro to attach the active word document to an email which I can then add body and subject too, again via the macro, I have previously been able to do an email macro but I cannot figure out how to combine them both, can anyone help, here is what I've got so far:
Excel to word macro: (it currently saves it to my documents)
Sub ControlWord()
Dim appWD As Word.Application
' Create a new instance of Word & make it visible
Set appWD = CreateObject("Word.Application.8")
appWD.Visible = True
Sheets("Template").Select
Range("A1:F15").Copy
' Tell Word to create a new document
appWD.Documents.Add
' Tell Word to paste the contents of the clipboard into the new document
appWD.Selection.paste
' Save the new document with a sequential file name
appWD.ActiveDocument.SaveAs Filename:="File" & i
' Close this new word document
appWD.ActiveDocument.Close
' Close the Word application
appWD.Quit
End Sub
Then this one creates a blank email with the suvject and body that I want:
Dim Email_Subject, Email_Send_From, Email_Send_To, _
Email_Cc, Email_Bcc, Email_Body As String
Dim Mail_Object, Mail_single As Variant
Email_Subject = "The subject of the email goes in here"
Email_Send_From = ""
Email_Send_To = "Randon@email.com"
Email_Cc = ""
Email_Bcc = ""
Email_Body = "The body of the email would go in here"
Set Mail_Object = CreateObject("Outlook.Application")
Set Mail_single = Mail_Object.CreateItem(0)
With Mail_single
.Subject = Email_Subject
.To = Email_Send_To
.cc = Email_Cc
.BCC = Email_Bcc
.Body = Email_Body
.send
End With
debugs:
If Err.Description <> "" Then MsgBox Err.Description
How do a smush these two together in one beautifully created macro?
Bookmarks