在使用PPT的时候,如果想与Access进行数据的交互,就必须使用VBA代码来实现:
如下的代码,其功能是,通过PPT读取ACCESS中的内容:
Public DbCnct As New ADODB.Connection
Public ReSet As New ADODB.Recordset
Private Sub CommandButton1_Click()
If DbCnct.State = adStateOpen And Not IsEmpty(adStateOpen) Then DbCnct.Close
DbCnct.Provider = "microsoft.jet.oledb.4.0"
DbCnct.ConnectionString = "test.mdb" ’数据库名称
DbCnct.Open
If ReSet.State = adStateOpen And Not IsEmpty(adStateOpen) Then ReSet.Close
ReSet.Open "test", DbCnct, adOpenDynamic, adLockOptimistic '表名称
TextBox1.Text = ReSet!mingzi
TextBox2.Text = ReSet!xingbie
TextBox3.Text = ReSet!dizhi
ReSet.Close
Set ReSet = Nothing
Set DbCnct = Nothing
End Sub