Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Launching Access from Excel VBA using SHELL

Status
Not open for further replies.
Mar 12, 2001
30
0
0
GB
Can anybody help?

I am trying to launch an access database using the shell function in excel VBA. Unfortunately the pathname has spaces in it therefore I am experiencing problems.

Can anyone suggest what I need to do to the following code in order to make it work? :

Dim RetVal As Variant

RetVal = Shell("x:\ACCESS.97\OFFICE\MSACCESS.exe V:\Modelling Analysis\Adhoc Work Requests\Work in Progress\David\overruns.mdb", 3)

Thanks in advance for any assistance!

Dee
 
What error message are you getting, there shouldn't be a problem with spaces in the path name?
 
Thanks for responding "psudeke".

I get the following error msg....

"The command line you used to start Microsoft Access contains an option that Microsoft Access doesn't recognise. Exit and restart Microsoft Access using a valid command-line prompt".

Any ideas..?
 
Have you tried this way of opening your database

Dim AcApp As Object
On Error Resume Next 'ignore error if Excel not running
Set AcApp = GetObject("Access.Application") 'Check for Word
If Err <> 0 Then
Set AcApp = CreateObject(&quot;Access.Application&quot;) 'Open Word
End If
On Error GoTo 0 'reset error handling
AcApp.Visible = True 'Make Word Visible
AcApp.opencurrentdatabase &quot;S:\Contacts DB\ContactsDatabase.mdb&quot;
 
Ignore the comments in the code of my last post which was modified from opening word in Access

A case of more haste less speed!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top