ms-access - 通过 VBA 连接 Powerpoint 和 Access?

标签 ms-access vba powerpoint

我有一张包含文本框的 Powerpoint 幻灯片。我想将这些文本框与 Access 中数据表的筛选 View 链接起来。

例如,如果我在 Access 中有一个任务列表应用程序,它显示具有不同优先级和效果的任务;有没有办法打开该文件,选择该 View ,并根据从我的 Powerpoint 演示文稿触发的 vba(或其他)onclick 按钮事件对其进行过滤?

最佳答案

当然可以从 Powerpoint 获取 Access 数据。

您需要确保在 VBA 项目中设置了对 Microsoft DAO 对象库的正确引用。

然后,要填充 PowerPoint 演示文稿中的文本框,您可以调用类似以下函数的函数,例如,返回一个包含与给定 TaskPriority 匹配的任务列表的字符串。

Function GetTaskListFromAccess(taskPriority as Integer) as String
  Dim db As DAO.Database
  Dim rs As DAO.Recordset
  Dim listOfTasks as String

  Set db = DBEngine.OpenDatabase(“C:\my_database.accdb”)

  Set rs = db.OpenRecordset("SELECT * FROM TaskTable WHERE TaskPriority=" & _
                            taskPriority, dbOpenSnapshot)
  If not rs is nothing then
    If rs.RecordCount > 0 then
      With rs
        While Not .EOF
          if listOfTask = "" then 
            listOfTasks = !TaskName
           Else 
            listOfTasks = listOfTasks & vbCrLf & !TaskName
          End If
          .MoveNext
        Loop
      .Close
      End With
    End If
    Set rs = nothing
  End If
  Set db = nothing

  GetTaskListFromAccess = listOfTasks
End Function

关于ms-access - 通过 VBA 连接 Powerpoint 和 Access?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/358722/

相关文章:

.net - 将 .NET Double.MinValue 插入 Access "Double"字段

ms-access - 如何关闭(卸载)表单

excel - 未触发 VBA 组合框更改事件

vb.net - 使用 OpenXml 更改 Powerpoint 上的文本值不合适

php - sql UPDATE 语句因 SQL 错误而失败

java - 无法连接到 MS Access 数据库

excel - 使用 Excel 进行字符串操作 - 如果存在字符串的一部分,如何删除其中的一部分?

vba - 使用 VBA 隐藏数据透视表

javascript - 用于在 Web 应用程序的 HTML 上实现 PowerPoint 查看器的选项(除了嵌入提供的 i-frame 标记之外)

php - CakePHP 将 html/数据导出为 PowerPoint 格式