익명 18:51

How to to compact an MS Access database file using VBA code with Microsoft Offic...

How to to compact an MS Access database file using VBA code with Microsoft Office 365 64-bit [closed]

I need the VBA code to do the Access Compact and Repair routine.

The following code fails with Access 64-bit.

Dim objJE As Object
Set objJE = CreateObject("JRO.JetEngine")
If Not objJE Is Nothing Then
  objJE.CompactDatabase _
  GetDBProvider & "Data Source=" & dbFileName & ";Jet OLEDB:Database Password=" & DBPW, _
  GetDBProvider & "Data Source=" & tempFile & ";Jet OLEDB:Database Password=" & DBPW
End If
Set objJE = Nothing

'GetDBProvider code is 
#If Win64 Then
' 64-bit Office CANNOT use Jet. It must use ACE.
GetDBProvider = "Provider=Microsoft.ACE.OLEDB.12.0;"
#Else
' 32-bit Office defaults to legacy Jet
GetDBProvider = "Provider=Microsoft.Jet.OLEDB.4.0;"
#End If


Top Answer/Comment:

Comment: google.com/search?q=compact+access+database+64+bit+office

상단 광고의 [X] 버튼을 누르면 내용이 보입니다