Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 05-03-2016, 03:04 PM
derajlance derajlance is offline Email from Command Button Windows 10 Email from Command Button Office 2013
Novice
Email from Command Button
 
Join Date: May 2016
Posts: 18
derajlance is on a distinguished road
Default Email from Command Button

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!
Attached Files
File Type: docm Test.docm (35.3 KB, 12 views)

Last edited by macropod; 05-03-2016 at 06:17 PM. Reason: Added code tags
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Submit to Email Command Button rob7676 Word VBA 0 08-20-2015 05:05 AM
Help with a Command Button dkohnken Word VBA 5 03-18-2015 10:13 PM
Email from Command Button command button that generates a popup for sending email oduntan Word VBA 4 03-21-2013 02:15 PM
Email from Command Button Command button - save in temp folder and send email with attachment bigbird69 Word VBA 13 11-18-2012 10:06 PM
Email from Command Button Command Button cksm4 Word VBA 7 02-27-2011 08:47 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 06:51 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft