Hide Access when macro run from Excel


G

Guest

I have copied the following code from the MS KB - it works OK but how can I
stop Access becoming visible while the macro runs?

Sub Run_Access_Macro()

Application.ScreenUpdating = False
'Opens Microsoft Access and the file nwind.mdb
Shell ("c:\program files\microsoft office\office\msaccess.exe
c:\apps\data\access\myfile.mdb")

'Initiates a DDE channel to Microsoft Access
Chan = DDEInitiate("MSACCESS", "system")
'Activates Microsoft Access
Application.ActivateMicrosoftApp xlMicrosoftAccess
'Runs the macro "Sample AutoExec" from the NWIND.MDB file
Application.DDEExecute Chan, "mymacro"
'Terminates the DDE channel
Application.DDETerminate Chan

Application.ScreenUpdating = True
End Sub
 
Ad

Advertisements

D

Dave Patrick

If you can convert the macro to VBA then something like this may work.

Dim appAccess, strConPathToDB
strConPathToDB = "D:\data\Access\db1.mdb"
Set appAccess = CreateObject("Access.Application.10")
appAccess.OpenCurrentDatabase strConPathToDB
appAccess.DoCmd.OpenModule "Module1", "SomeProc"
appAccess.Quit

--
Regards,

Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.microsoft.com/protect

:
|I have copied the following code from the MS KB - it works OK but how can I
| stop Access becoming visible while the macro runs?
|
| Sub Run_Access_Macro()
|
| Application.ScreenUpdating = False
| 'Opens Microsoft Access and the file nwind.mdb
| Shell ("c:\program files\microsoft office\office\msaccess.exe
| c:\apps\data\access\myfile.mdb")
|
| 'Initiates a DDE channel to Microsoft Access
| Chan = DDEInitiate("MSACCESS", "system")
| 'Activates Microsoft Access
| Application.ActivateMicrosoftApp xlMicrosoftAccess
| 'Runs the macro "Sample AutoExec" from the NWIND.MDB file
| Application.DDEExecute Chan, "mymacro"
| 'Terminates the DDE channel
| Application.DDETerminate Chan
|
| Application.ScreenUpdating = True
| End Sub
|
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top