VBA/Excel/Access/Word/Application/Dialogs — различия между версиями

Материал из VB Эксперт
Перейти к: навигация, поиск
м (1 версия)
 
(нет различий)

Текущая версия на 12:46, 26 мая 2010

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