[Webinar] Streamline your web hosting managementRegister Today


Shell statement returns error 5 "Invalid procedure call or argument"

Posted on 2004-10-25
Medium Priority
Last Modified: 2008-02-01
Hello all

The following lines return an "Invalid procedure call or argument" runtime error #5, and I have no idea why:

sShellPath = chr(34) & "c:\Windows\Notepad.exe " & sDestinationPath & chr(34)
dbl = Shell(sShellPath, vbMaximizedFocus)

sDestinationPath is a valid path/file, sShellPath is a string, Notepad is at the above path, and dbl is a double.  

I also tried this referencing Wordpad, and the file at sDestinationPath is not read-only.

I'm using Windows XP SP2/Access XP.

Thanks in advance.
Question by:Jim Horn
  • 2
LVL 34

Accepted Solution

flavo earned 2000 total points
ID: 12405741
Hey Jim!

Use this mate.

sShellPath = "Notepad.exe " & Chr(34) & sDestinationPath & Chr(34)
dbl = Shell(sShellPath, vbMaximizedFocus)

LVL 66

Author Comment

by:Jim Horn
ID: 12405769
Worked like a charm.  'Spanks...  -Jim
LVL 34

Expert Comment

ID: 12405800
You just had the " (chr(34)'s) in the wrong spot

Also, you dont need to pass the win dorectory to it either... You may have had issues if you moved your app to a different V of Windows (Win2K = c:\winnt\)

Take care mate!


Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Access has a limit of 255 columns in a single table; SQL Server allows tables with over 255 columns, but reading that data is not necessarily simple.  The final solution for this task involved creating a custom text parser and then reading…
Sometimes MS breaks things just for fun... In Access 2003, only the maximum allowable SQL string length could cause problems as you built a recordset. Now, when using string data in a WHERE clause, the 'identifier' maximum is 128 characters. So, …
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Enter Foreign and Special Characters Enter characters you can't find on a keyboard using its ASCII code ... and learn how to make a handy reference for yourself using Excel ~ Use these codes in any Windows application! ... whether it is a Micr…
Suggested Courses

640 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question