Hi everybody!
I'm new here and I desperatly need help. With the following function I
try to see a a device:
Public Function PortTest(COMPortNummer As Integer) As Boolean
MSComm1.CommPort = COMPortNummer
On Error Resume Next
MSComm1.PortOpen = True
If Err = 0 Then
PortTest = True
MSComm1.PortOpen = False
Else
PortTest = False
MSComm1.PortOpen = False
End If
End Function
For Portzaehler = 1 To 16
If PortTest(Portzaehler) Then
MsgBox "COM" + Str(Portzaehler) + " verfügbar"
End If
Next
The problem is that the compiler says to me that the command
"MSComm1." is error. It seems that I have to put a definition, and I
have no clue how to do it. I'm not a programmer, but I urgently need a
solution. Might it be that I have to add a line like "MSComm1.CommPort
= 1", and if yes, where to put it? Thank you for any kind of help!
Best wishes, Gremlin
ksjent@gmail.com - 19 Dec 2007 19:21 GMT
> Hi everybody!
>
[quoted text clipped - 28 lines]
>
> Best wishes, Gremlin
If someone could send me the example code in english (mine is german
version) would be even better!
Tony Strazzeri - 20 Dec 2007 08:39 GMT
I think you don't have any resource that communicates with the comm
port. VBA certainly doesn't have this. I think this may be available
in the "MSComm32.ocx" Activex control. If you have it installed you
can add a reference to it from your VBA IDE under References.
I think it odd that you are posting the query to an MS Word group.
Anyway a quick search using "how to open CommPort vba" came up with a
couple of worthwhile directions including the above control.
Have a look at these;
http://www.tech-archive.net/Archive/Excel/microsoft.public.excel.programming/200
4-05/7068.html
http://mc-computing.com/languages/SerialIO.htm
http://www.activexperts.com/activcomport/howto/vba/
I can't vouch for any of these but they seemed worth a look.
Good Luck
Cheers
TonyS.
> > Hi everybody!
>
[quoted text clipped - 31 lines]
> If someone could send me the example code in english (mine is german
> version) would be even better!
ksjent@gmail.com - 20 Dec 2007 15:07 GMT
> I think you don't have any resource that communicates with the comm
> port. VBA certainly doesn't have this. I think this may be available
[quoted text clipped - 51 lines]
> > If someone could send me the example code in english (mine is german
> > version) would be even better!
Thank you very much Tony!
I'm sorry about posting the message to a word group.
I realized afterwards that this is not a general vba discussion.