Consulting

Results 1 to 2 of 2

Thread: Using a barcode scanner with Excel

  1. #1

    Using a barcode scanner with Excel

    Hi All,
    I am looking at a way to use a handheld bar code scanner and input the data into a worksheet.
    What i need to do is the following
    1: Scan cabinet serial number into cell C3 (9 characters in total for serial number)
    2: Scan module 1 serial number into Cell D3 (12 characters in total for serial number)
    3: Scan module 2 serial number into Cell E3 (12 characters in total for serial number)
    each time the serial number is scanned i want to automatically jump to the next column and enter the serial number and jump to next column

    once i have those 3 items scanned i then want to jump down to the next row and continue doing the same.

    I know there has to be some VBA code here but i have no clue where to start.

    Can someone help me out please
    Last edited by Mr_Mod; 05-12-2016 at 05:49 AM.

  2. #2
    VBAX Regular
    Joined
    Apr 2016
    Posts
    11
    Location
    I am trying to do the same thing... but use USB GPS to record into excel. I don't know how to do it yet

    but here is part of code to use

    Sub OpenPort_Click()
    Dim intPortID As Integer ' Ex. 1, 2, 3, 4 for COM1 - COM4
        Dim lngStatus As Long
        Dim strData   As String
        Dim datFeed As String:  datFeed = ""
        Dim i As Integer
    intPortID = 1
    ' Open COM port
        lngStatus = CommOpen(intPortID, "COM" & CStr(intPortID), "baud=9600 parity=N data=8 stop=1")
    'cycle through Com ports 1-8 until found or not there
        If lngStatus <> 0 Then
            For i = 2 To 8
            Call CommClose(intPortID)
            intPortID = i
            lngStatus = CommOpen(intPortID, "COM" & CStr(intPortID), "baud=9600 parity=N data=8 stop=1")
                If lngStatus = 0 Then
                    Exit For
                End If
            Next i
        End If
    If lngStatus <> 0 Then
            MsgBox "Error: lngStatus = " & lngStatus
        ' this should get the strData untill end of file.
        Else
            MsgBox "Com Port Open"
            Do While CommRead(intPortID, strData, 64) <> EOF
                datFeed = datFeed + strData
            Loop
            ' this is blank, no data colected, help
            MsgBox datFeed
        End If
    Call CommClose(intPortID)
    End Sub
    Last edited by Aussiebear; 05-12-2016 at 09:41 PM. Reason: Enclosed code with hash tags

Posting Permissions

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