|
Dim strProveder As String Dim strOldPathName As String, strNewPathName As String Dim strOldConn As String, strNewConn As String Dim strJetDp As String Dim JRO As New JRO.JetEngine strProveder = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" strOldPathName = ThisWorkbook.Path & "\data.mdb" strNewPathName = ThisWorkbook.Path & "\back.mdb" strJetDp = ";Jet OLEDB:Database Password=123" strOldConn = strProveder & strOldPathName & strJetDp strNewConn = strProveder & strNewPathName & ";Jet OLEDB:Encrypt Database=True" & strJetDp If Dir(strNewPathName) <> "" Then Kill strNewPathName JRO.CompactDatabase strOldConn, strNewConn Set JRO = Nothing 'Kill strOldPathName 'Name strNewPathName As strOldPathName |
|