XL5 Docerr: Shell Function Pathname and Windowstyle Parts

Last reviewed: March 27, 1997
Article ID: Q111282
5.00 5.00c 7.00 WINDOWS kbdocerr

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 95, 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


KBCategory: kbdocerr
KBSubcategory:

Additional reference words: 7.00 5.00
Keywords : kbdocerr
Version : 5.00 5.00c 7.00
Platform : WINDOWS


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: March 27, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.