I'm relatively new to VBA & trying to automatize inserting a picture in several Word documents. So in the Word document I made a picture content control. I gave this content control the title "insert_pict". Now in my Macro, how can I add
I have this code so far:
Sub picturecc()
Dim Word_path As String
Dim Imagelocation As String
Word_path = "template.docm"
Imagelocation = "C:\Users\XXX\Desktop\Picture1.png"
Documents(Word_path).Activate
With ActiveDocument
.SelectContentControlsByTitle("insert_pict")(1).Range.InlineShape.AddPicture (Imagelocation)
End With
End Sub
But I get the error "method or data member not found" in the line .SelectContentControlsByTitle("insert_pict")(1).Range.InlineShape.AddPicture (Imagelocation). What is the right way to add the pricture to the content control? Can anyone help me out to get this work? Very much appreciate it.
Use:
With ActiveDocument
.InlineShapes.AddPicture Imagelocation, , , .SelectContentControlsByTitle("insert_pict")(1).Range
End With