I'm trying to communicate an Excel Sheet with a device that communcates using a Serial port. I have mode some research and found a lot of paid software that does this for you. However, I really want to make it by myself and do it directly from Excel using VBA. The problem is, I'm not good enough at VBA and finding tutorials or example has been difficult. Maybe my question is off the topic but I really need help. I tried this Macro code but Excel crashes.
Sub Read_Serial()
Open "COM3" For Binary Access Read Write As #1
'--------------------------------------------------------
answer = "" 'clear response string
char = Input(1, #1) 'get first character
While (char <> Chr(13)) 'loop until [CR]
If (char > Chr(31)) Then
answer = answer + char 'add, if printable char
Else
' Do what ever you like
End If
char = Input(1, #1) 'get the next character
Wend
Close #1
'--------------------------------------------------------
Cells(1, 1) = answer 'put response in cell("A1")
End Sub
Thanks for reading and sorry if I made a mistake typing my question, english is not my native language.