PDA

View Full Version : Using a barcode scanner with Excel



Mr_Mod
05-12-2016, 03:16 AM
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

hehanhan
05-12-2016, 10:28 AM
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