The information in this article applies to:
SUMMARY
In Microsoft Excel, when you use a Visual Basic for Applications procedure
to run a built-in dialog box, you must know the correct order of the
arguments for the corresponding macro function if you want to set initial
values in the dialog box. For example, to set initial values in the
Save As dialog box, you must know the order of the arguments for the
SAVE.AS macro function.
MORE INFORMATIONIn Visual Basic, arguments names are defined for properties and methods. Because the arguments are named, you can list them in any order or omit arguments without leaving commas as a placeholders. Using Named ArgumentsFor example, the following is the syntax for the SaveAs methodobject.SaveAs(filename, fileFormat, password, writeResPassword, readOnlyRecommended, createBackup)where the SaveAs method arguments are listed in the parentheses. The following is an instruction in Visual Basic that uses this method with only the filename and createBackup arguments: ' Using Named arguments ActiveWorkbook.SaveAs createBackup:=True, FileName:="BUDGET.XLS"Note that you do not have to list the arguments in any particular order, and you do not have to use commas as placeholders for the omitted arguments. To Display a Built-In Dialog Box with Initial ValuesIf you use the Show method to display the Save As dialog box, you must know the order of the arguments for the corresponding Save.As macro command to set initial values in the dialog box.The syntax for the Save.As macro command is the following SAVE.AS(document_text, type_num, prot_pwd, backup, write_res_pwd, read_only_rec)where the arguments are included in the parentheses in their correct order. If you want display the Save As dialog box with only the document_text and backup initial values set, you must indicate the missing arguments with commas, or use the named arguments arg1, arg2, through arg30 to specify the correct order. To display the Save As dialog box with BUDGET.XLS in the File Name box and the Always Create Backup option selected as initial values, use either of the methods below: Using Commas As Placeholders' Using arguments in correct order with commas as placeholders Application.Dialogs(xlDialogSaveAs).Show "BUDGET.XLS", , , TrueThe extra commas after the filename value are placeholders for the missing arguments. Note that if you use commas as placeholders for missing arguments, trailing commas at the end of an instruction can be omitted. In the example above, it is not necessary to add additional commas after the final argument used (backup). -or- Using Show Method Named Arguments' Using arg1, arg2, ... arg30 to provide the position of arguments Application.Dialogs(xlDialogSaveAs).Show arg1:="BUDGET.XLS", arg4:=TrueREFERENCESFor more information about the Dialog Object or the Show Method, choose the Search button in Help and type: built-in dialog boxes Additional query words: 97
Keywords : |
Last Reviewed: August 26, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |