VBA/Excel/Access/Word/Application/Dialogs — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
|
(нет различий)
|
Версия 16:33, 26 мая 2010
Содержание
- 1 cancel a procedure if the user clicked the Cancel button in a dialog box:
- 2 Display one of Excel"s built-in dialog boxes and let the user make the choices: by using the Application object"s Dialogs property.
- 3 Returning the Button the User Chose in a Dialog Box
- 4 Set the contents of the File Name text box in the Save As dialog box in Word and then display the dialog box
- 5 Specifying a Timeout for a Dialog Box
- 6 To display Excel"s Open dialog box
- 7 Using an Application"s Built-in Dialog Boxes from VBA: wdDialogFileOpen
cancel a procedure if the user clicked the Cancel button in a dialog box:
Sub dlg()
If Dialogs(wdDialogFileOpen).show = 0 Then End
End Sub
Display one of Excel"s built-in dialog boxes and let the user make the choices: by using the Application object"s Dialogs property.
Sub show()
Result = Application.Dialogs(xlDialogFormulaGoto).show
End Sub
Returning the Button the User Chose in a Dialog Box
Return Value Button Clicked
-2 Close
-1 OK
0 Cancel
1 The first command button
2 The second command button
>2 Subsequent command buttons
Set the contents of the File Name text box in the Save As dialog box in Word and then display the dialog box
Sub show()
With Dialogs(wdDialogFileSaveAs)
.Name = "Yellow Paint Primer"
.show
End With
End Sub
Specifying a Timeout for a Dialog Box
Sub dlg2()
With Dialogs(wdDialogToolsOptions)
.DefaultTab = wdDialogToolsOptionsTabUserInfo
.show (15000)
End With
End Sub
To display Excel"s Open dialog box
Sub showDialog()
Application.Dialogs(xlDialogOpen).show
End Sub
Using an Application"s Built-in Dialog Boxes from VBA: wdDialogFileOpen
Sub box()
If Documents.Count = 0 Then
Proceed = MsgBox("no document.Please open a document.", vbOKCancel + vbExclamation, "Format Report")
If Proceed = vbOK Then
Dialogs(wdDialogFileOpen).Show
If Documents.Count = 0 Then End
Else
End
End If
End If
End Sub