PDA

View Full Version : Sleeper: MSComm1.ComPort = 1 won't debug.



Scannerman
11-10-2004, 02:08 AM
I Hope somebody can point me in the right direction here.

I want to write a VB program to log data from a serial device directly to an Excel spreadsheet via the PC COM port. The program will run as a macro within Excel. The problem is that I can't get any of the MSComm lines to debug. I get a "runtime error 424: Object required" on any line that begins with MSComm1.

I'm using Visual Basic 6.3 in Excel 2002 (10.2614.3501)SP1

I've included MSComm32.ocx in my project references and closed the design mode but no joy. What have I missed?

Ken Puls
11-10-2004, 10:13 AM
Hi Scannerman, welcome to the board!

I'm not really sure I'll be much help to you here, but could you post the code you're using (or an excerpt from it)? It'll be far easier to troubleshoot if we can see what we're working with.

Cheers,

Ken Puls
11-10-2004, 11:44 PM
Found this post (http://www.mrexcel.com/board2/viewtopic.php?t=81488&highlight=mscomm) which may be of some help to you...

HTH,

Scannerman
11-11-2004, 01:01 AM
Thanks Ken. Here's what I've done so far. Its a Macro in the attached Excel spreadsheet. For the time being I'll be satisfied with what I think is a simple process to check the status of the COM port, Port Open True or Port Open False. It doesn't do anything useful but it can be tested without an external device connected.

What the code should do is to step through the rows in the sheet "Users" and for each row display a message box showing port status and the value of the cell in column A. What happens is that when I try to debug it I get the error:

Runtime Error '424'
Object Required

on the line MSComm1.ComPort = 1.

If I comment that line the same error comes up on the next line.

I think the problem is that I've not included the MSComm OCX correctly. It's there in Tools>References but doesn't appear in the Properties list.

Scannerman
11-11-2004, 01:06 AM
Sorry Ken. I didn't see your link until after I'd sent my reply. Looks like that's the answer. I can't do it in Excel with MSComm.ocx. I'll just have to find another ocx.

Thanks for your help anyway. I'm very new to programming, learning all the time.