|
稍微修改即可实现你的需求。
- Sub cclean()
- Dim cat As Object, mytable As Object
- Dim cnn As Object
- Dim SQL$, a$, b$, mydata$
- Set cat = CreateObject("ADOX.Catalog")
- Set cnn = CreateObject("ADODB.Connection") '设置连接
- mydata = ThisWorkbook.Path & "\OK.mdb"
- cat.ActiveConnection = "Provider = microsoft.ACE.oledb.12.0 ; data source=" & mydata & ";jet oledb:database password=123456;"
- cnn.Open cat.ActiveConnection '打开连接
- 'On Error Resume Next
- For Each mytable In cat.Tables
- If mytable.Type = "TABLE" Then
- ''clean and clear records for all tables
- SQL = "DELETE FROM " & mytable.Name & ""
- cnn.Execute SQL '执行脚本
- End If
- Next
- cnn.Close '关闭连接
- Set cnn = Nothing
- Set mytable = Nothing
- Set cat = Nothing
- End Sub
复制代码 |
评分
-
1
查看全部评分
-
|