How to change a picture into Word doc by another picture using Excel VBA

paulosq

New Member
Joined
Dec 13, 2012
Messages
2
Experts, please, I need help.


How do I replace a figure (type 13, msoPicture) in a Word document by a figure that is on the clipboard, maintaining the characteristics (position, alignment, page size) of the image that is in the Word?


What happens is that I have a macro in Excel that runs through all the worksheets in a workbook, individually copying intervals and graphics, previously defined and pasting these as .PNG or .WMF objects within a Word document.


The macro already does the same thing in PowerPoint and works perfectly, but there are days when I'm trying to do the same thing in Word and I can not. Always occurs some different error.

I am using MS Office 2013 32-bits over Windows 8.1 64-bits


I appreciate any help and apologize for my bad English.
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Oi Paulo

See if this helps:
Code:
'Excel module
Sub PauloSq()
Dim wap As Word.Application, h%, w%
Set wap = GetObject(, "Word.Application")
wap.Visible = True
With ActiveDocument.InlineShapes(1)     ' replace first Word picture
    h = .Height
    w = .Width
    .Select
End With
    Sheets("Plan1").Shapes(2).Copy      ' with second Excel picture
    wap.Selection.Paste
With ActiveDocument.InlineShapes(1)
    .Height = h
    .Width = w
End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,664
Messages
6,173,654
Members
452,525
Latest member
DPOLKADOT

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