0
votes

I would like to embed a Word document into my Excel file and have the VBA to open it, add a table I have from the Excel file, and copy-paste all in an email. Is there a way to open an embedded Word document with VBA instead of giving a folder path? Here is my VBA (it works fine). I guess the way is to add as an object (?). Thanks!

Private Sub ToggleButton1_Click()

Dim ol As Outlook.Application
Dim olm As Outlook.MailItem
Dim wd As Word.Application
Dim doc As Word.Document
Dim rng As Range
Set ol = New Outlook.Application
Set olm = ol.CreateItem(olMailItem)
Set wd = New Word.Application
wd.Visible = True
Set doc = wd.Documents.Open(Environ$("USERPROFILE") & "\Desktop\US - Dec.docx")
lr = Sheet4.Range("A" & Application.Rows.Count).End(xlUp).Row
ThisWorkbook.Worksheets("Webinars").Range("A27:D" & lr).Copy
doc.Paragraphs(17).Range.PasteExcelTable _
                        LinkedToExcel:=False, _
                        WordFormatting:=False, _
                        RTF:=False
doc.Content.Copy
With olm
.Display
.To = ""
.Subject = ""
Set Editor = .GetInspector.WordEditor
Editor.Content.Paste
Application.CutCopyMode = False
'.Send
 End With
 Set olm = Nothing
 Application.DisplayAlerts = False
doc.Close SaveChanges:=False
 Set doc = Nothing
wd.Quit
 Set wd = Nothing
 Application.DisplayAlerts = True

End Sub
1
Does this answer your question? VBA Excel open Word ObjectTimothy Rylatt

1 Answers

0
votes

I provided you the answer with the working code in your previous posting of this same question.

VBA Excel open Word Object