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

On Feb 20, 10:38*am, tomcee wrote:
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


Fwiw:

I found that my VB4 has the same issue!!!

So, I installed this mscomm32.ocx:
===========================
mscomm32.ocx 103744 6-24-98

and registered it via:
regsvr32 c:\windows\system32\mscomm32.ocx

and things seem to work fine in Excel2003 !!!

It also fixed the issue in VB4!!!

It appears that there was a port close issue with the older
mscomm32.ocx that I was using!

Cheers!!
TomC