When you say "control passes to the error handler," did you forget to add Exit Sub? In your comments, you say you added a new ad, but still have a problem? Well, I just ran this code and it had no problems opening the port.
Private Sub Form_Load()
Dim MSComm1 As New MSComm
On Error GoTo cant_open_com1
MSComm1.CommPort = 1
MSComm1.Settings = "9600,N,8,1"
MSComm1.DTREnable = True
MSComm1.Handshaking = comRTS
MSComm1.InBufferSize = 12 + 1
MSComm1.RThreshold = MSComm1.InBufferSize
MSComm1.RTSEnable = True
MSComm1.InputLen = 0
MSComm1.InputMode = comInputModeText
MSComm1.NullDiscard = True
MSComm1.OutBufferSize = 0
MSComm1.SThreshold = MSComm1.OutBufferSize
MSComm1.PortOpen = True
Exit Sub
cant_open_com1:
Debug.Print Err.Description
End Sub
source
share