Kick off access using excel.

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I am trying to start access using excel and run a macro. There are two
problems.

1.) I get an error when I try to open access on the "Y:" drive. The Y drive
is a shared drive at work that I have access to. My hard drive is drive "C:"

Call Shell("C:\Program Files\Microsoft Office\OFFICE11\MSACCESS.EXE
Y:\Building.mdb")

Error Message = ...
'The command line you used to start Microsoft Office Access contains an
option that microsoft Office Acess doesn't recognize.
'Exit and restart Microsoft Office Access using valid command-line options.

2.) Do you know the syntax to use to start "Macro1" in the database?


Thanks for your help!!
 
One other thing. I get the same error when I copy the database to the C:
drive so the code reads.
Call Shell("C:\Program Files\Microsoft Office\OFFICE11\MSACCESS.EXE
C:\Building.mdb")

Error message is the same .
 
Sub tryThis()
Dim objAcc As Object
On Error GoTo ender
Set objAcc = CreateObject("Access.Application")
objAcc.OpenCurrentDatabase _
"Y:\Building.mdb"
objAcc.Visible = True
With objAcc
.DoCmd.RunMacro ("Macro1")
End With
closer:
Set objAcc = Nothing
Exit Sub
ender:
MsgBox Err.Description
Resume closer
End Sub
 
Back
Top