Insert a picture into a Word document

mikeymay

Well-known Member
Joined
Jan 17, 2006
Messages
1,624
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

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Why did you add the .Range property after rngHeader?
 
Upvote 0
Solution

Forum statistics

Threads
1,221,310
Messages
6,159,176
Members
451,543
Latest member
cesymcox

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