0

I am trying to use winsock control (MSWINSCK.OCX produced with VB6) in my Excel. Here are what I have done:

1, download MSWINSCK.ocx from internet, copy to c:\windows\SysWOW64

2, run regsvr32 C:\Windows\SysWOW64\MSWINSCK.OCX with administrator successfully

3, import below registry file according to suggestion from internet:

REGEDIT HKEY_CLASSES_ROOT\Licenses = Licensing: Copying the keys may be a violation of established copyrights.

// Winsock Control 6.0 license key HKEY_CLASSES_ROOT\Licenses\2c49f800-c2dd-11cf-9ad6-0080c7e7b78d = mlrljgrlhltlngjlthrligklpkrhllglqlrk

4, open my Excel visual basic windows

5, insert a user form

6, from tools->reference, browse the above .ocx file, and select Microsoft Winsock Control 6.0

7, put a commandbutton onto the userform, double click it to add below codes:

  Dim tcpclient As New Winsock

  tcpclient.Connect "localhost", 5100

Up to now, everything seems ok. when I input "tcpclient." the system even prompt me with .Accept .Close .Connect .....
Sounds great.

Then I start to run the userform, and I click the commandbutton, then received error: Run Time Error -2147221164(80040154) Class Not Registered

Could you please help me what's wrong?

I need to use the winsock control, in order to connect a TCP server from my Excel.

Thanks a lot!

user14921615
  • 1
  • 1
  • 1

2 Answers2

0

I suspect that your problem is that the library is 32-bit only ("SysWOW64" is for running 32-bit apps) but you are running a 64-bit version of Excel/VBA. You will probably find that running %systemroot%\System32\regsvr32.exe (64-bit) fails with a message like, "The module _____ may not be compatible with the version of Windows that you're running. Check if he module is compatible with an x86 (32-bit) or x64 (64-bit) version of regsvr32.exe" where as running %systemroot%\SysWoW64\regsvr32.exe succeeds.

See also:

jacobq
  • 11,209
  • 4
  • 40
  • 71
0

Winsock control may not available in all versions of Excel or on all systems. Try replacing the declaration and instantiation of the winsock object with the updated control:

  • Replace Dim winsock As Object with Dim winsock As MSWinsockLib.Winsock.
  • Replace Set winsock = CreateObject("MSWinsock.Winsock") with Set winsock = New MSWinsockLib.Winsock.
wz16
  • 3
  • 2