Microsoft KB Archive/111282

{|
 * width="100%"|

XL5 Docerr: Shell Function Pathname and Windowstyle Parts

 * }

-

The information in this article applies to:


 * Microsoft Excel for Windows, versions 5.0, 5.0c
 * Microsoft Excel for Windows NT, version 5.0
 * Microsoft Excel for Windows, version 7.0

-

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" Keywords :

Version : 5.00 5.00c 7.00

Platform : WINDOWS

Issue type :

Technology :