我对VBA比较陌生&;想在几个Word文档中自动插入一张图片。所以在Word文档中我做了一个图片内容控件。我给这个内容控件取了一个标题 "insert_pict"。现在,在我的Macro中,我怎样才能添加
到目前为止,我有这段代码。
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
但是我在.SelectContentControlsByTitle("insert_pict")(1).Range.InlineShape.AddPicture(Imagelocation)这一行得到了 "方法或数据成员未找到 "的错误信息。怎样才能把pricture添加到内容控件中呢?谁能帮我解决这个问题?非常感谢。
使用。
With ActiveDocument
.InlineShapes.AddPicture Imagelocation, , , .SelectContentControlsByTitle("insert_pict")(1).Range
End With