首页 > 解决方案 > 如何使用vba在includepicture字段中发送图像路径

问题描述

我有一个具有表单的访问数据库。此表单中有一个提交按钮。当我单击此按钮时,我正在运行一些 vba 代码。如果所有代码都运行成功,我将创建带有 docvariables 的 ms word 文档。所以我想在 includepicture 字段中发送图像路径,为此我写了这段代码

{INCLUDEPICTURE {DOCVARIABLE PICTURE}\* MERGEFORMAT}

我在我的word文档中使用了上面的代码。这些是我的 vba 代码,我在我的访问数据库表中获取图像路径。

  Dim imgPath As String
  Dim imgName As String
  Dim imgPath_rp As String
  Dim db_image As DAO.Database
  Dim rs_image As DAO.Recordset

    Set db_image = OpenDatabase("C:\Users\ftk1187\Desktop\Test WS_11-Jun-2018 - Copy.mdb", False, False, "")
    Set rs_image = db_image.OpenRecordset("SELECT * FROM TableSıgnature WHERE ImageName = '" & Me.Combo474.Value & "'", dbOpenDynaset)


    If Me.Combo474.Value = rs_image!ImageName Then
        imgPath = rs_image!imagePath
    End If

    imgPath_rp = Replace(imgPath, "\", "\\")

  rs_image.Close
  Set rs_image = Nothing
  db_image.Close

  objDOC.Variables("PICTURE").Value = imgPath_rp

当我单击提交按钮时,它没有给我任何错误,但图像无法显示。

标签: vbams-accessms-word

解决方案


推荐阅读