XL5 Docerr: Shell Function Pathname and Windowstyle Parts

ID: Q111282

5.00 5.00c 7.00 WINDOWS kbdocerr

The information in this article applies to:

SUMMARY

In Microsoft Excel, Visual Basic Help contains incorrect information about the pathname and windowstyle parts of the Shell function.

Pathname

In the description of the pathname part, Help states that "[the shell function] may also be the name of a document that has been associated with an executable program."

This information is incorrect.

You will receive an error message (even if the documents exist and are properly associated with applications) if you use the commands:

   Shell ("c:\excel\network.txt")

   -and-

   Shell ("c:\winword\sample.doc")

The shell function cannot launch another program if the name of a file associated with that program is passed to the shell function. If the pathname argument is the name of a document, not the name of an application, you will receive the error message

   Run-time error '5':
   Invalid procedure call

To work around this situation, include the name of the application. as in the following examples:

   Shell ("notepad.exe c:\excel\network.txt")

   -or-

   Shell ("c:\winword\winword.exe c:\winword\sample.doc")

Windowstyle

The text implies that the windowstyle argument can be used to determine the window size and focus status of the launched application. This information is only partially correct: if windowstyle is included, you must enter a variable name and equal sign to the left of the Shell command in order for the command to be accepted.

The Shell statement cannot stand alone when the argument is used. For example, this command will work

   RetVal = Shell ("c:\windows\calc.exe", 2)

but this command will not:

   Shell ("c:\windows\calc.exe", 2)

If you attempt to enter this second line, you will receive the error message "Expected: )" and the comma in the command will be highlighted.

MORE INFORMATION

To find the Shell Function in Help, choose the Search button in Visual Basic Help and type:

    Shell

KBCategory: kbdocerr KBSubcategory:

Additional reference words: 7.00 5.00

Version           : 5.00 5.00c 7.00
Platform          : WINDOWS

Last Reviewed: March 29, 1997