Results 1 to 2 of 2

Thread: excel comm vba

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2013
    Posts
    6

    excel comm vba

    i am trying to read info sent from a device via comm port I get an error #35 "compilation error a sub or function has not been defined"

    This is my code, can anyone help me


    Code:
    Private Sub MSComm1_OnComm()
    
    If Worksheets("SerialPort").MSComm1.CommEvent = comEvReceive Then
    Call GetData
    End If
    
    
    End Sub
    Sub OpenPort()
    
    'Open the COM Port with the relevant settings
    
    Worksheets("SerialPort").MSComm1.CommPort = 4
    Worksheets("SerialPort").MSComm1.Settings = "9600,n,8,1"
    Worksheets("SerialPort").MSComm1.RThreshold = 1
    Worksheets("SerialPort").MSComm1.InBufferSize = 4096
    Worksheets("SerialPort").MSComm1.PortOpen = True
    
    
    End Sub
    
    
    Private Sub GetData()
    
    Dim MyData As String
    
    Wokrsheets("SerialPort").MSComm1.InputLen = 0
    
    MyData = Worksheets("SerialPort").MSComm1.Input
    ActiveCell.Value = MyData
    
    MyData = ""
    
    Worksheets("SerialPort").MSComm1.PortOpen = False
    
    End Sub
    
    
    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    
    If Not Intersect(Target, Columns("A:A")) Is Nothing Then
    
    If Target.Value = "" Then
    
    Call OpenPort
    
    End If
    End If
    
    Application.EnableEvents = True
    
    End Sub

  2. #2
    Member
    Join Date
    Mar 2013
    Posts
    35

    Re: excel comm vba

    You spelled Worksheets wrong:

    Wokrsheets("SerialPort").MSComm1.InputLen = 0

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width