Thread: Sendkeys
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson[_5_] Dave Peterson[_5_] is offline
external usenet poster
 
Posts: 1,758
Default Sendkeys

Look at application.onkey.

Option Explicit
Sub RunMyF6Macro()
Application.OnKey "{f6}", "RunMyF6"
End Sub

Sub RunMyF6()
MsgBox "hi from F6"
End Sub

'And this would toggle it back to normal.
Sub PutItBack()
Application.OnKey "{f6}"
End Sub




Jim wrote:

Hi I cant work out which worksheet function to use to
spark off some code if the button F6 is pressed.

I know it is something like -

Sub Worksheet_Whats this??()

If Application.SendKeys(vbKeyF6) Then
MsgBox ("you pressed F6")
End
End If

End Sub

Thanks
Jim


--

Dave Peterson