Make sure you do not have Home switches enabled in Ports and Pins as you do not need them when homing externally.
Next Operator menu then Edit Button Script and then click on the flashing RefAll button.
In the editor you will need to enter the VB suitable for what you want to do. As an example here is what I have on the lathe, I am using my PLC to send and accept the signals from the servo so the I/O is via Modbus but you could just quite as easily use general I/O in ports and pins and alter the VB accordingly.
Do
Call SetModOutput (21,1) 'Activate ModOutPut 20
If GetInput(19) Then Exit Do 'Loop until ModInPut 18 is seen
Sleep (10)
Loop
End If
Call SetModOutPut (21,0) 'DeActivate ModOutPut 20
DoOemButton (1024) 'Set Z axis Home
Do
Call SetModOutPut (20,1)
If GetInput(18) Then Exit Do
Sleep (10)
Loop
End If
Call SetModOutPut (20,0)
DoOemButton (1022)
Hood