【问题标题】:VBA: Content control; filename of a pictureVBA:内容控制;图片的文件名
【发布时间】:2020-09-21 10:34:02
【问题描述】:

我对 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

但我在 .SelectContentControlsByTitle("insert_pict")(1).Range.InlineShape.AddPicture (Imagelocation) 行中收到错误“未找到方法或数据成员”。将图片添加到内容控件的正确方法是什么?谁能帮我完成这项工作?非常感谢。

【问题讨论】:

    标签: vba ms-word word-contentcontrol


    【解决方案1】:

    用途:

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

    【讨论】:

      猜你喜欢
      • 2023-03-08
      • 1970-01-01
      • 1970-01-01
      • 2014-04-11
      • 1970-01-01
      • 1970-01-01
      • 2012-09-14
      • 1970-01-01
      • 2015-12-27
      相关资源
      最近更新 更多