Dont Call me Betty
New Member
- Joined
- Sep 29, 2023
- Messages
- 19
- Office Version
- 365
- Platform
- Windows
Followed below instructions for the below code, only for step 7 there were no "Microsoft Outlook Object Library", so used "Microsoft Outlook 16.0 Object Library "
But nothing happens when code runs, at all, not even an error.
Using below code as a next best thing to figuring out how to incorporate that part into VBA I run in Excel to generate that word file.
So, added custom button to QAT in Word for below code -- will have to just make another click. Need it to work for any active word file, not just for a specific one.
Objective is to have an X% zoom screenshot of an open Word document to be placed into a generated email, with that Word document also attached.
But nothing happens when code runs, at all, not even an error.
Using below code as a next best thing to figuring out how to incorporate that part into VBA I run in Excel to generate that word file.
So, added custom button to QAT in Word for below code -- will have to just make another click. Need it to work for any active word file, not just for a specific one.
Objective is to have an X% zoom screenshot of an open Word document to be placed into a generated email, with that Word document also attached.
VBA Code:
Option Explicit
Sub eMailActiveDocument()
Dim OL As Object
Dim EmailItem As Object
Dim Doc As Document
Application.ScreenUpdating = False
Set OL = CreateObject("Outlook.Application")
Set EmailItem = OL.CreateItem(olMailItem)
Set Doc = ActiveDocument
Doc.Save
With EmailItem
.Subject = "Insert Subject Here"
.Body = "Insert message here" & vbCrLf & _
"Line 2" & vbCrLf & _
"Line 3"
.To = "User@Domain.Com"
.Importance = olImportanceNormal 'Or olImprotanceHigh Or olImprotanceLow
.Attachments.Add Doc.FullName
' .Send
End With
Application.ScreenUpdating = True
Set Doc = Nothing
Set OL = Nothing
Set EmailItem = Nothing
End Sub
How to use: |
|
Test the code: |
|