I am sure this has been asked before, but I can't seem to find a solution that is actually working. I am very new at VBA, so I apologize in advance.
I have a Word document with drop down lists, text boxes, and a command button. My ultimate goal is to allow my employees to fill out the drop down lists and text boxes, then have them click the command button and the information be sent to me in the body of an email.
I need it to follow the same
I have tried multiple times with information I found from Google, but nothing seems to be working. At this moment, I am using the following:
Code:
Private Sub CommandButton1_Click()
ActiveDocument.Content.Copy
Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objInspector As Outlook.Inspector
Dim objDoc As Word.Document
Set objOutlook = CreateObject("Outlook.Application")
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
With objOutlookMsg
.To = "recipient@domain.com"
.Subject = "Report"
.Body = ActiveDocument.Content
.Send
End With
Set objInspector = objOutlook.ActiveInspector
If Not objInspector Is Nothing And objInspector.EditorType = olEditorWord Then
Set objDoc = objInspector.WordEditor
objDoc.Range.Paste
End If
Set objDoc = Nothing
Set objOutlookMsg = Nothing
Set objInspector = Nothing
Set objOutlook = Nothing
End Sub
The problem seems to be with the code:
Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objInspector As Outlook.Inspector
Dim objDoc As Word.Document
As well as:
.Body = ActiveDocument.Content
I have unprotected the file and attached it here.
Any help would be greatly appreciated!