100% found this document useful (1 vote)
1K views3 pages

How To Read Serial Port Data in Excel 2007

This document provides instructions on how to read serial port data in Excel 2007 using the StrokeReader ActiveX control. It describes how to insert the control, set its properties to connect to a serial port, and use VBA code to receive incoming barcode data and write it to cells. The code accumulates incoming data, looks for line feed characters to separate barcodes, and stores the barcodes in consecutive cells as they are received. This allows Excel to read data from devices like barcode scanners in real-time.

Uploaded by

Deepak Singla
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
1K views3 pages

How To Read Serial Port Data in Excel 2007

This document provides instructions on how to read serial port data in Excel 2007 using the StrokeReader ActiveX control. It describes how to insert the control, set its properties to connect to a serial port, and use VBA code to receive incoming barcode data and write it to cells. The code accumulates incoming data, looks for line feed characters to separate barcodes, and stores the barcodes in consecutive cells as they are received. This allows Excel to read data from devices like barcode scanners in real-time.

Uploaded by

Deepak Singla
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

20/12/2014

HowtoreadserialportdatainExcel2007

HowtoreadserialportdatainExcel2007
AnexamplehowtoplacetheStrokeReaderserialportActiveXonExcel2007spreadsheetandreaddatafromRS232
port,USBbarcodescannerorRS485equippedweightingmachine.

Settingupthedevelopertab
1.RunMicrosoftExcel2007usingStartbutton>AllProgramsmenu.

StrokeReaderActiveX

AboutStrokeSeader
Developerzone
Download/Buy
Propertiesandmethods
Programmingexamples
Excel2007
Access2010
VB.NET(new)
JavaScript

2. First, we need to set up the Excel's Ribbon to show the Developertab. Click on the OfficeButton and then on
ExcelOptions.

JavaScript+Binarydata
NonActiveX

SerialportprogrammingwithWinAPI

3. In the Popular group, check the Show Developer tab box and then press OK at the bottom of Excel Options
dialog.

HowtoinserttheserialportActiveXusingDevelopertab
1.OntheDevelopertab,clickontheInsertControlsbuttonandthenchooseMoreControls.

2.FromthecomponentlistintheMoreControlsdialog,chooseStrokeReader.

3.RightclickontheserialportobjecticonandthenchoosePropertiesfromthecontextmenu.

https://strokescribe.com/en/readserialportexcel2007.html

1/3

20/12/2014

HowtoreadserialportdatainExcel2007

4.InthePropertiesbox,set:
PortThedesiredserialportnumber(seePortsAvailablepropertyforthelistofserialportsavailableonyour
PC).
BaudRateThedatatransferspeed.9600isthemostpopularsettingfordataexchangewithbarcode
scanners.
DataModeWeareplanningtoreadonlyASCIIbasedbarcodes,sosetthispropertytoTEXTandallincoming
datawillberepresentedasusualVBtextstrings.
DataBitsThenumberofdatabits(5,6,7or8)ineachtransferredbyte.Setthevalueto8.
PARITYThedatavalidationschemeusedbytheserialport.NOPARITYisthemostcommonsetting.
STOPBITSThenumberofstopbitssent(orexpectedtobereceived)aftereachbyte.Setthisvalueto1.
ConnectedSetthistoTruetoconnecttotheserialport.Readthepropertyvaluetoseetheconnectionstatus.
TheActiveXwillautomaticallyreconnecttoUSBadapterwhenitreattachedtoPC.
NOTE: These are the most common values used to set up the data transfer with the most of barcode scanners.
Pleasealwaysconsulttoyourscannerprogrammer'smanual,ifunsure.

HowtoreceivethedatawithVBAprogram
1.DoubleclickontheserialportActiveXicon.PastethefollowingcodeintoVisualBasiceditorwindow.
DimbufAsString'Bufferforincomingserialdata
Dimcell_idxAsInteger'Therownumbercelltostoreareceivedbarcode
PrivateSubStrokeReader1_CommEvent(ByValEvtAsStrokeReaderLib.Event,_
ByValdataAsVariant)
SelectCaseEvt'CanbeEVT_DISCONNECTorEVT_DATAorEVT_SERIALEVENT

CaseEVT_DISCONNECT'ifUSBserialportadapterisjustdisconnectedfromthePC
MsgBox"Serialportconverterdisconnected"
CaseEVT_CONNECT
MsgBox"Connected"'ifRS232orRS485portadapterisjustconnectedtoUSBbus

CaseEVT_DATA'Incomingserialdata

https://strokescribe.com/en/readserialportexcel2007.html

2/3

20/12/2014

HowtoreadserialportdatainExcel2007

buf=buf+data'Incomingserialdataaccumulatedinbuf

Do
LF=InStr(buf,Chr(10))'MostofscannerssendASCII<LF>aftereachbarcode

IfLF=0ThenExitDo'WaitingforASCII<LF>tobereceived

s=Left(buf,LF1)'Copythedatabefore<LF>codeasthebarcodetext
s=Replace(s,Chr(13),"")'Somescannerscouldsend<CR><LF>.Remove<CR>ifpresent

buf=Right(buf,Len(buf)LF)'Cuttheparseddatafromthebuffer
'Thisisusefuliftheexternalhardwaresendsmultiplebarcodesinatime.

cell_idx=cell_idx+1'incrementtherownumberofcellwherethebarcodewillbestored
Cells(cell_idx,1)=s
Loop

EndSelect
EndSub

2.GobacktotheExcelwindowandexittheDesignmodebyclickingonDesignmodebutton:

3.ScansomebarcodesandseehowtheywillplacedintoExcelcells:

BARCODEGENERATION

TECHNOLOGIES

SERIALPORTPROGRAMMING

QRCode

VB6

Serialport/Excel

NEWSANDUPDATES

EAN13

VB.NET

Serialport/VB.NET

StrokeScribeversionhistory

DataMatrix

ASP.NET

SerialportAPIinVB6

StrokeReaderversionhistory

Code128

Excel

GS1128

Access

RSS

SITEPOLICIES
Privacypolicy
Refunds

(c)20082014strokescribe.com

https://strokescribe.com/en/readserialportexcel2007.html

3/3

You might also like