Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


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
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

597 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