The below code works great when you call an unsecured database from another database. But I am trying to compact an .mdb in Office 2013 that has user-level security (.mdw).
If I try the below code with an .mdb with .mdw and try and compact the open database I get error 3045, file in use.
If I try the below code with an .mdb with .mdw and try and compact a different database I get error 3033, do not have necessary permissions.
If anyone has a solution that would be wonderful. Thank you in advance!
Public Function CompactAndRepairAccessDB()
Dim Acc As Object
Set Acc = CreateObject("access.application")
Dim dbPath As String, dbPathX As String
dbPath = "\\servername\database.mdb"
dbPathX = "\\servername\databaseTEMP.mdb"
Acc.DBEngine.CompactDatabase dbPath, dbPathX
Acc.Quit
Set Acc = Nothing
Kill dbPath
Name dbPathX As dbPath
End Function