I have a code that copy text from "Sheet1" of excel to a word document and also copy an image on "Sheet1" of excel to a word doc, but for the text it creates a word document and for the image it creates another word document, I need the text and the image to be inserted in the same document, how could I do that?
This is the code:
****************************************************************************
Sub ExportToWord_Example2()
Dim WordApp As Word.Application
Dim doc As Word.Document
Dim rng As Range
Dim appwd As Object
Set WordApp = CreateObject("Word.Application")
With WordApp
.Visible = True
Set doc = .Documents.Add
End With
For Each rng In Sheet1.UsedRange
With doc.Paragraphs(doc.Paragraphs.Count).Range
.Text = rng.Text
.Font.Bold = rng.Font.Bold
.Font.Color = rng.Font.Color
End With
doc.Range.InsertParagraphAfter
Next rng
Set appwd = GetObject(, "Word.Application")
appwd.Visible = True
appwd.Documents.Add
Worksheets("Sheet1").Shapes("Imagen 1").Copy
appwd.Selection.Paste (wdPasteDefault)
End Sub
********************************************************************************
Thanks for the support
This is the code:
****************************************************************************
Sub ExportToWord_Example2()
Dim WordApp As Word.Application
Dim doc As Word.Document
Dim rng As Range
Dim appwd As Object
Set WordApp = CreateObject("Word.Application")
With WordApp
.Visible = True
Set doc = .Documents.Add
End With
For Each rng In Sheet1.UsedRange
With doc.Paragraphs(doc.Paragraphs.Count).Range
.Text = rng.Text
.Font.Bold = rng.Font.Bold
.Font.Color = rng.Font.Color
End With
doc.Range.InsertParagraphAfter
Next rng
Set appwd = GetObject(, "Word.Application")
appwd.Visible = True
appwd.Documents.Add
Worksheets("Sheet1").Shapes("Imagen 1").Copy
appwd.Selection.Paste (wdPasteDefault)
End Sub
********************************************************************************
Thanks for the support