Refer InlineShape a replace with a image

drom

Well-known Member
Joined
Mar 20, 2005
Messages
543
Office Version
  1. 2021
  2. 2019
  3. 2016
  4. 2013
  5. 2011
  6. 2010
  7. 2007
Hi and Thanks in advance!

I have a word template
  • I have to populate a few word marks from excel using vba (no problem)
In my word Template a Have a shape, is the only one
so when I use:

VBA Code:
Dim objWord As Object:           Set objWord = CreateObject("Word.Application")
                                 objWord.Visible = True
Dim wFxFullName as String:       wFxFullName=range("A4")  'This file always Exists 
Dim wImgFullName as String:      wImgFullName=range("A5") 'This Image file always Exists 
Dim objDoc As Object:            Set objDoc = objWord.Documents.Add(Template:=wFxFullName, NewTemplate:=False, DocumentType:=0)

Debug.Print objDoc.InlineShapes.Count         'always Shows 1
Dim iShape As InlineShape:       Set iShape =objDoc.InlineShapes(1)


iShape.LockAspectRatio = msoFalse
iShape.select
Debug.Print iShape.Height, iShape.Width       'Goes OK
Debug.Print iShape.Top, iShape.Left           'Does not show anything, goes wrong 


'MY MINE PROBLEN
'This line goes WRONG:

Selection.AddPicture (wImgFullName)

So How can I refer to my selected Ishape to Add a image located in my PC ??

My Idea is to replace this kind of shape (this iShape) with a new one using Excel's VBA, I mean from Excel

I know how insert a image in word but not how to replace the iShaoe using his size Top, Left, width and Height
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.

Forum statistics

Threads
1,223,234
Messages
6,170,891
Members
452,366
Latest member
TePunaBloke

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