Socket Programming in VBA

2

I recently spent many hours vainly searching online tech groups for code related to socket programming in Visual Basic for Applications (VBA) so that I could easily write VBA to enable tools developed in MS Excel or Access to “surf the web” to download data etc. Finally, I found the following utility:

http://www.ostrosoft.com/oswinsck.asp#inst

This code, when pasted into your ‘This Worksheet’ object in the MS Excel VBA editor, for example, gets the raw html from a specified URL. NB – to run this example you may need to add a reference to the OSWINSCKdll file in the VBA editor.

2 Comments

  1. David Osucha

    December 25, 2007 @ 3:03 am

    1

    Steve:

    I also found the OstroSoft product. Listen, I found your blog doing a simple Google search of sockets+VBA. I am working in a commercial application requiring a computer to function as a server to one host and a client to another host, and the programming needs to be done in VBA which leaves me stranded with respect to VB.NET and/or VB6 classes.

    I have reviewed OstroSoft’s product, and believe I can use it, but find myself woefully clueless with the fundamental concepts of how a socket works and the approach to programming one in VBA. Are you aware of a reference on the web, or even hard cover, that explains how one should program a socket? I mean, I am asking questions like: “When I am listening, does my code need to loop until something happens, and if so, what?” “Once connected, will a connection ever self-terminate or must I call a method to disconnect?” “What is the normal format for data being transferred?” “Is it best to connect, send data and then disconnect, or just remain connected continuing to look for new data to arrive?” “Does OstroSoft’s socket control only work within a VB UserForm, or can it be created within a regular module? A Class Module?”

    I would appreciate any response from you as I have become desperate with a deadline approaching.

    Sincerely — David O.

  2. Sonny P

    July 29, 2010 @ 10:02 am

    2

    Well well well… I was looking at doing the exact same thing for so long but couldn’t find any thing helpful. I’ve even took online courses in Access VBA and Excel VBA and begin investigating designing my own tool but nothing work.

    The tool you suggested works perfectly and I wish I found this earlier.

    Thanks heaps!

    Sonny P

Log in