PDA

View Full Version : Problem with Excel - Access macro



Phelony
06-09-2010, 03:57 AM
hi Guys :hi:

I'm trying to get Access to open and run a macro from Excel. Ultimately this will close access after it has run the process as I don't want users to be able to access the database directly.

However, I'm having some problems getting the code to run. I have Excel referenced to the Microsoft Access 11.0 Object Library but am still getting a Runtime Errror 7866 claiming that the database is open by another user or missing, neither is true. :dunno

Can anyone suggest\advise where I'm going wrong? I have searched the forum and have tried a solution suggested, but this doesn't seem to be taking effect. Using 2003 because they won't give me anything better!! :help

Sub RunAccessMacro()
Dim appAccess As Object
Const strConPath = "Y:\Planning and Performance\Access\"
strDB = strConPath & "Revenue Test 2.mdb"
Set appAccess = CreateObject("Access.Application")

With appAccess
Application.DisplayAlerts = False
.OpenCurrentDatabase strDB
.DoCmd.OpenModule "Revenue Upload"
.Run "Normalupload"
'.Quit
End With
Set appAccess = Nothing
End Sub

Thanks

Phel x

Kenneth Hobs
06-09-2010, 06:22 AM
Did you try?
.DoCmd.OpenModule "Revenue Upload", "Normalupload"