Insert a picture into a Word document

mikeymay

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

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Why did you add the .Range property after rngHeader?
 
Upvote 0
Solution

Forum statistics

Threads
1,224,818
Messages
6,181,151
Members
453,021
Latest member
Justyna P

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