PDA

View Full Version : Solved: EXCEL communicating with hyperterminal



itays
06-02-2009, 01:29 AM
hi,
i am trying to cause information gathered through the hyperterminal communication connection (COM1) at windows XP, to flow into an Excel sheet.
is it possible to create using VBA code at the excel prog.?
does anyone have a similar vba code?

live long and prosper,
itays

Oorang
06-02-2009, 10:08 AM
Two ways I know of:
If you have Visual Studio 6 then you can use the Microsoft Communications Control: http://www.pencomdesign.com/support/relay_software/vba_software_example.htm
http://msdn.microsoft.com/en-us/library/aa231237(VS.60).aspx (http://msdn.microsoft.com/en-us/library/aa231237%28VS.60%29.aspx)

Otherwise you are stuck using the Win32 API
http://msdn.microsoft.com/en-us/library/ms810467.aspx (http://www.vbaexpress.com/forum/showthread.php?t=26979)

Threads on this here:
http://stackoverflow.com/questions/569698/what-is-the-best-way-to-access-a-serial-port-from-vba
http://www.tek-tips.com/viewthread.cfm?qid=560230&page=1

There appears to be a working example here: http://www.thescarms.com/vbasic/commio.aspx

itays
06-03-2009, 01:41 AM
thanks!
you really made it the great!
:hi:
itays

Emily
06-05-2009, 07:07 AM
Two ways I know of:
-----
Otherwise you are stuck using the Win32 API
http://www.vbaexpress.com/forum/showthread.php?t=26979
-----

This link seemed show this thread only , can you update it

thanks

Oorang
06-05-2009, 12:41 PM
That was supposed to have been: http://msdn.microsoft.com/en-us/library/ms810467.aspx

Emily
06-05-2009, 11:06 PM
Thanks

Felix88
08-15-2013, 03:34 AM
thanks!you really made it the great!:hi:itaysHi,My code is as below and I used exactly the same from the working example. However, I got an error " Compile error: Sub or function not defined"Would you mind to share with me the code see if which part of the code I might have missed.Thanks. Sub TESTIOICC() Dim intPortID As Integer ' Ex. 1, 2, 3, 4 for COM1 - COM4 Dim lngStatus As Long Dim strError As String Dim strData As String ' Initialize Communications lngStatus = CommOpen(intPortID, "COM" & CStr(intPortID), _ "baud=9600 parity=N data=8 stop=1") If lngStatus 0 Then ' Handle error. lngStatus = CommGetError(strError) MsgBox "COM Error: " & strError End If ' Set modem control lines. lngStatus = CommSetLine(intPortID, LINE_RTS, True) lngStatus = CommSetLine(intPortID, LINE_DTR, True) ' Write data to serial port. lngSize = Len(strData) lngStatus = CommWrite(intPortID, strData) If lngStatus lngSize Then ' Handle error. End If ' Read maximum of 64 bytes from serial port. lngStatus = CommRead(intPortID, strData, 64) If lngStatus > 0 Then ' Process data. ElseIf lngStatus < 0 Then ' Handle error. End If ' Reset modem control lines. lngStatus = CommSetLine(intPortID, LINE_RTS, False) lngStatus = CommSetLine(intPortID, LINE_DTR, False) ' Close communications. Call CommClose(intPortID)End Sub