Insert a picture into a Word document

mikeymay

Well-known Member
Joined
Jan 17, 2006
Messages
1,632
Office Version
  1. 365
Platform
  1. Windows
I am trying to use the following to insert a picture into the header of a Word document
VBA Code:
strPath = ActiveWorkbook.Path

'Hold the full path of the picture to be inserted into Word
strClientLogo = Range("FD_ClientLogoPath")

'Word session creation
Set appWord = CreateObject("Word.Application")

appWord.Visible = True

'open the template .doc file
Set docWord = appWord.Documents.Open(strPath & "\Template Client Output.docx")

'Access the header range only need to add to page 2 onwards of the Word doc
Set rngHeader = docWord.Sections(2).Headers(1).Range
    
'Insert the image into the header
Set picWord = rngHeader.Range.InlineShapes.AddPicture(strClientLogo)
The code errors on the last line above with a Run Time error 438 Object doesn't support this property.

I had previously used
VBA Code:
rngHeader.InlineShapes.AddPicture strClientLogo
but I need to move, change the size, etc of the image that has been inserted so I need to assign it to an object variable somhow.


TIA
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
Why did you add the .Range property after rngHeader?
 
Upvote 0
Solution

Forum statistics

Threads
1,223,886
Messages
6,175,196
Members
452,616
Latest member
intern444

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