Code:
Private Sub MyButton_Click()
rslinx = OpenRSLinx()
DDEPoke rslinx, "N7:0", Cells(1, 1)
End Sub
Private Function OpenRSLinx()
On Error Resume Next
'Open the connection to RSLinx
OpenRSLinx = DDEInitiate("RSLINX", "My_Topic")
'Check if the connection was made
If Err.Number <> 0 Then
MsgBox "Error Connecting to topic", vbExclamation, "Error"
OpenRSLinx = 0 'Return false if there was an error
End If