Using VBA to create TCP connection to remote Temperature equipment using Ostrosoft or Winsock

jbelow2

New Member
Joined
Mar 23, 2010
Messages
13
Hi everyone,

I have been stumped on a small project (well I though it would be small) that would use an excel front end (using a form) and VBA to read the temperature and humidity of a ethernet connected temperature gauge and display the results on the form.

I have been trying to use "Ostrosoft" and "Winsock", but my code will not create the object. The code fails at the "Set wsTCP" step. Sample of code is below.

I have the "Ostrosoft Winsock Component" is enabled in the references and the "OSWINSCK.dll" registered.

The errorhandler just says it "Error 429: ActiveX component can't create object"
I get the same error whether using oswinsck or winsock.

I feel that I am missing something fundamental to get this to work.
A fee additional details:
I am using WIN7Professional 64 bit, Microsoft Office Professional Plus 2013.

Any ideas?
Thank You,
John

A sample part of my code is:

Option Explicit


Dim bytesTotal As Long
Dim sPage As String
Dim MbusQuery
Dim returnInfo
Dim wsTCPgdb
Dim WithEvents wsTCP As OSWINSCK.Winsock
Dim SetObject
Dim RetrieveData


Private Sub CommandButton1_Click() ' Retrieve Data
On Error GoTo ErrHandler
Dim sServer As String
Dim nPort As Long
Dim StartTime

DoEvents
nPort = 502 ' See configuration in Do-More Designer
' Set the IP address of the PLC
sServer = Sheets("Sheet1").Range("B4") ' ”192.168.1.3”
RetrieveData = 1
CommandButton1.BackColor = "&H0000FF00" 'Set colour to Green


'Check to see if the object has been created. If not set wsTCP.
If SetObject = "" Then
Set wsTCP = CreateObject("OSWINSCK.Winsock")
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
I am using windows 7 and office 2013. I have been unable to get an "mswinsck" object to be added to my form. I there a sequence of tasks that I should follow? I have tried regsvr32 to register the mswinsck and oswinsck ocx files. I do not have VB only VBA.

Anyone have any ideas how to get started? I think I must be missing something fundamental .
Thank You
John
 
Upvote 0

Forum statistics

Threads
1,223,248
Messages
6,171,027
Members
452,374
Latest member
keccles

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top