MS Office Forum

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds

Accessing SERIAL Port from Excel VBA

  Asked By: Boell    Date: Dec 16    Category: MS Office    Views: 26822

Is it possible to access Serial Ports or
any other device from within Excel VBA?
How to go about doing this?

I am required to write a set of macros
which will output a set of random strings
to COM Port and use this to test an
equipment. I am successful in creating
the set of random commands. I don't know
how to connect to Serial port.



7 Answers Found

Answer #1    Answered By: Balbir Kaur     Answered On: Dec 16

Yes, it can be done. You will have to use the MSCOMM activex.


I have not personally used MSCOMM to communicate with serial  devices from VBA (I
have done it with VB6). I did work on a project that communicated with GPIB and
Modbus devices, however. Getting the serial port  to work should be no problem.

Answer #2    Answered By: Rene Sullivan     Answered On: Dec 16

I *think* it would be possible using ordinary batch files.

You used to be able to use the dos COPY command to copy to a device.

Generating a batch file is relatively easy.

First off though ... If you choose to try this ... Check out the dos COPY
command to see if you can write  to the serial  port.

It should read something like ...
Copy <File/String> COM1

Answer #3    Answered By: Milton Robinson     Answered On: Dec 16

There is a dll available on the net called inpout32.dll which can be used
to communicate with the serial  or parallel port.

I would be interested to know how you go about with your project and what
kind of device  you are trying to control?

Answer #4    Answered By: Vinit Online     Answered On: Dec 16

What about talking to a USB port  ? Is there something for this. (laptops with
no serial  or parallel ports)

Answer #5    Answered By: Jake Williams     Answered On: Dec 16

It is transparent, the system sees it as another comm port. You just need to
know what the port  number is.

Answer #6    Answered By: Muriel Dunn     Answered On: Dec 16

I have neen doing it for several years now. I have seen three methods:
2 - Common Basic statements of OPEN, PRINT/WRITE, CLOSE and
3 - The method I use, API calls into the Kernel32.

I am using Excel 97 and it will not run MSCOMM. Something about not
being licenced or approved. I don't recall the exact wording of the
message I got when trying to load the MSCOMM module.

I can send you workbooks that have methods 2 & 3. I have seen MSCOMM
examples on the web as well. They may be large !! 3-4 meg. They
send out the serial  port to operate ham radios and are quite envolved,
but you should be able to use the module.

My method has one module with very good comments and was written by
someone who knew what he was doing.

Answer #7    Answered By: Nagaraj Kedda     Answered On: Dec 26

Hi Muriel Dunn,
Would you mind sharing the excel workbook as I am trying to do the same thing. Hope with your excel workbook, I can communicate with the device on the com port and send Hex strings.

Didn't find what you were looking for? Find more on Accessing SERIAL Port from Excel VBA Or get search suggestion and latest updates.