通过VBA链接Powerpoint和访问? [英] Linking Powerpoint and Access through VBA?
问题描述
我有一张包含文本框的Powerpoint幻灯片.我想将这些文本框与Access中数据表的筛选视图链接起来.
I have a Powerpoint slide that contains textboxes. I would like to link those textboxes with a filtered view of a data table in Access.
例如,如果我在Access中有一个TaskList应用程序,该应用程序显示具有不同优先级和影响的任务;有没有办法打开该文件,选择该视图并根据我的Powerpoint演示文稿触发的vba(或其他)onclick按钮事件对其进行过滤?
For ex, if I had a TaskList application in Access that displayed tasks with different priorities and affectations; is there a way to open that file, select that view, and filter it according to a vba (or other) onclick button event triggered from my Powerpoint presentation?
推荐答案
当然可以从Powerpoint获取Access数据.
It's certainly possible to get Access data from Powerpoint.
您需要确保在VBA项目中为Microsoft DAO Object Library
设置了正确的引用.
You need to make sure you have the correct references set to theMicrosoft DAO Object Library
in your VBA project.
然后,要在PowerPoint演示文稿中填充文本框,可以调用类似于以下函数的内容,例如,返回一个包含与给定TaskPriority相匹配的Tasks列表的字符串.
Then, to populate your textbox in your PowerPoint presentation, you can call something like the following function, say, to return a string containing a list of Tasks matching the given 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
这篇关于通过VBA链接Powerpoint和访问?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!