question on key hit and focus
Is there a way to tell which control has the focus?
I want to pass a control to a specific function only if it has focus.
Also my second question is...I want to use F7 as a "Sendkeys" or keydown event..but how do I check if this button is clicked.
I want it at the form level...
basically user hits F7 .. and the text box that has the focus calls a specific function that takes as a parameter that control.
THanks,
Jon
Re: question on key hit and focus
:cry:
Err..I need a hasfocus..or an API that tells me what text box / control has the focus..
I took the majority of this from marty to spell check a box...
VB Code:
Public Function CheckSpelling(t As TextBox)
On Error GoTo Err_Handler
Dim objWord As Object
Dim objDoc As Object
Dim strResult As String
'Create a new instance of word Application
If (Len(t.Text) = 0) Then
'nahhhhhhhhhhh
Else
Set objWord = CreateObject("word.Application")
Select Case objWord.Version
'Office 2000, xp, 2k3
Case "9.0", "10.0", "11.0"
Set objDoc = objWord.Documents.Add(, , 1, True)
'Office 97
Case Else
Set objDoc = objWord.Documents.Add
End Select
objDoc.Content = t.Text
objDoc.CheckSpelling
strResult = Left(objDoc.Content, Len(objDoc.Content) - 1)
If t.Text = strResult Then
' There were no spelling errors, so give the user a
' visual signal that something happened
MsgBox "The spelling check is complete.", vbInformation + vbOKOnly, "Spelling Complete"
End If
'Clean up
objDoc.Close False
Set objDoc = Nothing
objWord.Application.Quit True
Set objWord = Nothing
' Replace the selected text with the corrected text. It's important that
' this be done after the "Clean Up" because otherwise there are problems
' with the screen not repainting
t.Text = strResult
End If
Done:
Exit Function
'in case user does not have word...
Err_Handler:
MsgBox Err.description & Chr(13) & Chr(13) & "Please note you must have Microsoft Word installed to utilize the spell check feature.", vbCritical, "Error #: " & Err.Number
Resume Done
End Function
But I want to call it and pass the text box that has the focus via say F7 key click. Right now Im not sure how to do this though
Anyone with some ideas?