|
本帖最后由 yuk_yu 于 2012-11-15 18:26 编辑
如何压缩有密码的Access2007
' Microsoft Jet and Replication Objects 2.6 Library
' Microsoft Office 12.0 Access Database engine Object Library
|
'现在的代码可以实现压缩,但没有打开的密码了,如何实现压缩后access的密码还是存在并且还是原来的密码??
Sub Button1_Click()
CompactDatabse_2007_JRO ThisWorkbook.Path & "\123.accdb", ThisWorkbook.Path & "\456.accdb"
End Sub
Function CompactDatabse_2007_JRO(ByVal SourceAccdb As String, ByVal TargetAccdb As String) As Boolean
On Error Resume Next
Dim JRO As JRO.JetEngine
Set JRO = New JRO.JetEngine
Dim strS As String
Dim strT As String
strS = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & SourceAccdb & ";Jet OLEDB:Database Password=123;"
strT = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & TargetAccdb & ";Jet OLEDB:Engine Type=5" '问题可能在这句!!!我不知怎么加密码
JRO.CompactDatabase strS, strT
If Err <> 0 Then
CompactDatabse_2007_JRO = False
Else
Kill ThisWorkbook.Path & "\123.accdb"
CompactDatabse_2007_JRO = True
Name ThisWorkbook.Path & "\456.accdb " As ThisWorkbook.Path & "\123.accdb "
End If
End Function
|
|