2014-05-20 56 views
1

我想通過「Shift + Click」(Shift鍵+鼠標點擊鼠標左鍵)在文本字段上設置Open FileDialog,它怎麼可能?如何在VBA Access上設置「Shift + Click」?

我寫這爲打開文件對話框:

Private Sub Article_Click() 
    Dim dialog As FileDialog 
    Set dialog = Application.FileDialog(msoFileDialogFilePicker) 
    With dialog 
    .AllowMultiSelect = False 
    .Show 
    Me.Article() = .SelectedItems(1) 
    End With 
End Sub 
+0

這是否幫助? http://office.microsoft.com/en-us/access-help/run-an-access-macro-by-using-a-keyboard-shortcut-HA010239111.aspx –

回答

1

您可以使用MouseDown事件文本框的確定按Ctrl的狀態,並使用Alt鍵鍵這裏描述的技術:

Detecting SHIFT, CTRL, and ALT States

的In y我們的情況下,如果你只關心移位鍵,那麼你可以使用這樣的事情:

Option Compare Database 
Option Explicit 

Dim ShiftTest As Integer 

Private Sub Article_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) 
    ShiftTest = Shift And 1 
End Sub 

Private Sub Article_Click() 
    If ShiftTest = 1 Then 
     Dim dialog As FileDialog 
     Set dialog = Application.FileDialog(msoFileDialogFilePicker) 
     With dialog 
      .AllowMultiSelect = False 
      .Show 
      Me.Article() = .SelectedItems(1) 
     End With 
    End If 
End Sub 
相關問題