Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 204
Default Microsoft comm controls

I am trying to open com1 in vb and get data from a tag reader as the tags are
read. I have started with this

Private Sub Worksheet_Activate()

' Open the serial port
MSComm1.CommPort = 1
MSComm1.Settings = "115200,N,8,1"
MSComm1.PortOpen = True

but it is giving me an error straight up. Do I need to download anything for
the MSComm1 commands to work. I realise I would need to put in loops etc for
it to continually monitor the port but I can't even get it to open the port
yet.

Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Microsoft comm controls

I don't know much about MSComm but looks like that should open your com-1,
silly question but do you actually have Com-1 available, try some others.

Someone from this ng sent me this to test a long time ago: with MSComm1 and
a couple of commandbuttons on the sheet -

Private Sub CommandButton1_Click()

' Sets/returns the baud rate, parity, data bit, and stop bit parameters.

MSComm1.CommPort = 4 ' start with comm port
MSComm1.Settings = "57600,N,8,1" ' 57600 baud, no parity, 8 data,
and 1 stop bit.
MSComm1.InputMode = comInputModeBinary ' BINARY MODE
MSComm1.DTREnable = True
MSComm1.RTSEnable = True
MSComm1.EOFEnable = False ' No end of file character
MSComm1.Handshaking = comNone
MSComm1.InputLen = 0 ' read FIFO until empty
MSComm1.RThreshold = 1 ' # of chars to receive before
generates the OnComm event
MSComm1.InBufferSize = 8192 ' 1024 is default

On Error GoTo Errorhandler

MSComm1.PortOpen = True
On Error GoTo 0
MsgBox "MSComm1.PortOpen " & MSComm1.PortOpen
Exit Sub
Errorhandler:
MsgBox "Bad settings", vbOKOnly, "Comm Port Error"
End Sub

Private Sub CommandButton2_Click()
If MSComm1.PortOpen Then
MSComm1.PortOpen = False
End If
MsgBox "MSComm1.PortOpen " & MSComm1.PortOpen
End Sub

The original code included
MSComm1.CommPort = 6
which failed for me because I didn't have 6, but 4 was good for me

Regards,
Peter T




"NDBC" wrote in message
...
I am trying to open com1 in vb and get data from a tag reader as the tags
are
read. I have started with this

Private Sub Worksheet_Activate()

' Open the serial port
MSComm1.CommPort = 1
MSComm1.Settings = "115200,N,8,1"
MSComm1.PortOpen = True

but it is giving me an error straight up. Do I need to download anything
for
the MSComm1 commands to work. I realise I would need to put in loops etc
for
it to continually monitor the port but I can't even get it to open the
port
yet.

Thanks



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Reading Comm Port in Excel SA Excel Programming 2 November 25th 08 03:55 PM
If And/Or statement for comm calc criteria Wannano Excel Discussion (Misc queries) 4 May 22nd 08 04:27 AM
Comm Add-ins gabch[_11_] Excel Programming 1 April 11th 06 01:51 PM
Comm 1 stark Excel Programming 0 October 28th 03 05:16 PM
Connecting to comm 1 Stark Excel Programming 2 October 27th 03 07:02 PM


All times are GMT +1. The time now is 12:50 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"