View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
TomCee TomCee is offline
external usenet poster
 
Posts: 32
Default MSCOMM32 Control in Excel 2003 VBA

I am experiencing very strange behaviour with the MScomm32 control in
Excel 2003 VBA.

The control is registered, and I can install it in my spreadsheet, but
when running (via Sub Worksheet Change), it appears to execute once (I
have a Belkin USB/RS232 adaptor which has status and TX/RX LEDs).

On successive executions, I get error messages that the port is
already open (I do set the PortOpen property to False at the end of
each run), but if I do not execute the .portopen to true, it returns
an error saying the port is not open!).

I am using MSCOMM32.ocx version 7-26-95, I believe installed with my
VB4.

Also, I notice that when I exit Excel, the status LED on the USB/RS232
adaptor blinks.

It seems to me that there is some setting in the com port status that
I am not maintaining or Set/resetting in the correct order.

Thanks in advance for your assistance!
TomC
--------------------------------------------------------

Here is my code:
[obviously with some commented remnants of my failed attempts.]

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
MSComm1.Enabled = True
'MSComm1.PortOpen = False
MSComm1.Activate
'MSComm1.PortOpen = False
'MSComm1.PortOpen = False
MSComm1.PortOpen = True
MSComm1.Settings = "9600,N,8,1"
MSComm1.Handshaking = NoHandshaking

'MSComm1.PortOpen = True
MSComm1.Output = "Hello out there!"
MSComm1.PortOpen = False
'MSComm1.Delete

End Sub