|
-
Jan 8th, 2006, 09:08 AM
#1
Thread Starter
New Member
Send RS232 string from Excel
Hi,
This is my first look at VB and I am a complete novice. What I need to do is create buttons on an excel spreadsheet that when clicked will send out preset strings to a com port.
My questions are:
Is it possible to create the code from within excel's editor?
I have tried running the following on a pc that doesn't have vb installed, but it obviously needs the MSCOMM to be running on the pc, which I can't seem to find out how to install.
Sub SERIAL_INIT() 'set up port
If mscomm1.PortOpen = True Then 'double check to avoid error if this sub re-called
mscomm1.PortOpen = False
End If
mscomm1.CommPort = 2 'portnumber
mscomm1.Settings = "9600,N,8,1" '9600 baud, no parity, 8 data and 1 stop
mscomm1.InputMode = comInputModeText 'text mode
mscomm1.InputLen = 1 'Set INPUT to read ONE char
mscomm1.RTSEnable = False 'disable
mscomm1.DTREnable = False 'disable
mscomm1.Handshaking = comNone 'for 3 wire connection
mscomm1.InBufferSize = 1024 '
mscomm1.PortOpen = True 'open the port
mscomm1.InBufferCount = 0
End Sub
Sub Preset3()
mscomm1.out = "Preset R 3" & cr & "ATRN" & cr
End Sub
Is there an easier way of sending the string in preset3() ??
I saw this on a website, but it doesn't work either (although it's simple enough for me to understand)
Sub Preset3()
Open "COM2:" For Output As #1 'or COM1
Print #1, "PRESET R 3" & Chr$(13) & "ATRN" & Chr$(13)
Close #1
End Sub
Any help or suggestions would be very appreciated!
Jonathan
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|