Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/vba/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
VBA:内容控制;图片的文件名_Vba_Ms Word_Word Contentcontrol - Fatal编程技术网

VBA:内容控制;图片的文件名

VBA:内容控制;图片的文件名,vba,ms-word,word-contentcontrol,Vba,Ms Word,Word Contentcontrol,我对VBA比较陌生&尝试在几个Word文档中自动插入图片。所以在Word文档中,我制作了一个图片内容控件。我给这个内容控件命名为“insert_pict”。现在在我的宏中,如何添加 到目前为止,我有以下代码: Sub picturecc() Dim Word_path As String Dim Imagelocation As String Word_path = "template.docm" Imagelocation = "C:\Users\XXX\Desktop\Picture1.p

我对VBA比较陌生&尝试在几个Word文档中自动插入图片。所以在Word文档中,我制作了一个图片内容控件。我给这个内容控件命名为“insert_pict”。现在在我的宏中,如何添加

到目前为止,我有以下代码:

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
但是我在行中得到错误“找不到方法或数据成员”。选择ContentControlsByTitle(“insert_pict”)(1)。Range.InlineShape.AddPicture(Imagelocation)。向内容控件添加原则的正确方法是什么?有人能帮我完成这项工作吗?非常感谢

使用:

With ActiveDocument
    .InlineShapes.AddPicture Imagelocation, , , .SelectContentControlsByTitle("insert_pict")(1).Range
End With