VBA copy image and text from excel sheet to word doc

Pipe9701

New Member
Joined
Feb 8, 2022
Messages
5
Office Version
  1. 365
Platform
  1. Windows
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
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Have you tried creating a template and then using bookmarks to indicate precisely where it should go?
 
Upvote 0
Have you tried creating a template and then using bookmarks to indicate precisely where it should go?
Thank you, I already solved it with this code:

*********************************************
Dim WordApp As Word.Application

Set WordApp = CreateObject("Word.Application")

With WordApp
Worksheets("Sheet4").Shapes("Imagen 1").Copy
.Selection.Paste
End With
***************************************************
 
Upvote 0
Solution

Forum statistics

Threads
1,213,487
Messages
6,113,937
Members
448,534
Latest member
benefuexx

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top