SendKeys with Function Key

PacVII

New Member
Joined
Jul 20, 2017
Messages
22
Office Version
  1. 365
I am having a bit of an issue trying to get the sendkey to work with a function key. works great with some functions like home and even tab, enter etc. I just can not get it to hit the F2 key. everything I see says to use {F2} but the {} do not work for me, I found success in the []. this works in the code below with the home function so I thought F2 would work the same. but when the macro gets to my F2 line it just types in F2 on the screen and is not hitting the F2 key? any ideas what I am doing wrong?



Sub testing()

'Link to Blue Zone
Set host = CreateObject("BZWhll.WhllObj")
ResultCode = host.Connect("A")
If (ResultCode <> 0) Then
MsgBox"Error: Unable to connect with BlueZone."

Exit Sub
End If

host.SendKeys"[Home]"
host.SendKeys"[F2]"

End Sub



 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
First, you are missing a space before every opening " character for your call to MsgBox and calls to SendKeys. For now I'll assume it's a copy/paste error since your code won't compile this way. (Also I suggest using CODE tags for better readability.)

Normally using SendKeys in Excel VBA does not require qualification. You would use it like this to send keystrokes to the active window:
Code:
SendKeys "{F2}"

But what is "Blue Zone", and what is the host object you are creating? That will use a completely different version of SendKeys so you have to conform to what that particular object wants.
 
Upvote 0
blue zone is a ibm mainframe (host) interface. im sure you remember the dark black screen days and knowing the commands to navigate through an mainframe application (lol, the good ol days). anyway I found a solution using a BlueZone VT Send Key Table I found online with some google help. the following does the job. Thanks for giving me a try.

Code:
host.SendKeys "@2"
 
Upvote 0
Code:
host.SendKeys "@2"
Glad you discovered that. This is not, strictly speaking, an Excel question. I do remember the IBM 3270 green screens but only because I'm old. :-)
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,176
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top