PRJ: Error Using Command Without Required Arguments (113272)
The information in this article applies to:
- Microsoft Project 98 for Windows
- Microsoft Project for Windows 95 4.1
- Microsoft Project for Windows 95 4.1a
- Microsoft Project for Windows 4.0
- Microsoft Project for the Macintosh 4.0
This article was previously published under Q113272 SYMPTOMS
In Microsoft Project, when you run a macro that contains a command that is
missing required arguments, you receive the following error message:
Argument not optional
Additionally, if you assign macro command to a toolbar without required
arguments, you receive the following error message:
Required argument not included
CAUSE
This behavior is by design in Microsoft Project. When you use a command in
a macro, or assign a command to a toolbar button, you must include required
arguments with the command.
One exception to this rule is a command that displays a dialog box, such as
FileOpen. When you use a command that displays a dialog box, you do not
necessarily need to include arguments, even if they are described as
required in the Visual Basic Reference. If the help topic for the command
states that the command displays a dialog box, you can use the command
without arguments to display the dialog box.
WORKAROUND
If you want to prompt a user for input, and use this input as an argument
for a macro command that does not display a dialog box, you can use the
InputBox function to store information from the user as a variable, then
use the variable as the value of the required argument. The following is a
simple example of how to use this method:
Sub Edit_View()
' Dimension variables
Dim ViewName, ViewTable, ViewFilter As String
' Prompt user for view to edit
ViewName = InputBox("Type name of single-pane view to edit")
' Prompt user for table to apply
ViewTable = InputBox("Type name of table to apply to view")
' Prompt user for filter to apply
ViewFilter = InputBox("Type name of filter to apply to view")
ViewEditSingle Name:=ViewName, Table:=ViewTable, _
Filter:=ViewFilter
End Sub
Note that the macro example would need to have error checking procedures to
test for valid user input.
Microsoft provides examples of Visual Basic procedures for illustration
only, without warranty either expressed or implied, including but not
limited to the implied warranties of merchantability and/or fitness for a
particular purpose. This Visual Basic procedure is provided 'as is' and
Microsoft does not guarantee that it can be used in all situations.
Microsoft does not support modifications of this procedure to suit customer
requirements for a particular purpose. Note that a line that is preceded by
an apostrophe introduces a comment in the code--comments are provided to
explain what the code is doing at a particular point in the procedure. Note
also that an underscore character (_) indicates that code continues from
one line to the next. You can type lines that contain this character as one
logical line or you can divide the lines of code and include the line-
continuation character.
Modification Type: | Major | Last Reviewed: | 11/25/2003 |
---|
Keywords: | kbcode kbProgramming KB113272 |
---|
|