It has been a while since I last made a post here. But I intend to get up to speed and publish on a more regular basis. Anyway, on the .NET platform and with VB.NET we can rather easy check if the computer we work on is connected to a network or not.
To know that information allows us:
- To run methods that update workbooks with the latest data.
- Run network located templates and individual workbooks.
- Load network based add-ins.
Technically we will be using the My namespace to find out if the computer is connected or not. More specifically we will use the My.Computer namespace which provides methods to control the computer’s hardware and the system software. Among other things, it allows us to work with the file system, clipboard, Windows Registry network printers, network connection and keyboard & mouse.
The following snippet code shows how we can use it to determine if the computer is connected to a network.

Because the property isAvailable only indicates if there is a network available or not we need to make sure that there is a connection to the network we actually want to access. In order to do so we use the Ping function to insure that the wanted remote location is available.
Kind regards,
Dennis
Hi Dennis,
This is a good example of why we might want to use .Net over VBA.
It’s so much simpler and faster that VBA would be at doing the same thing, not in all case of course, but at this it is!
Ross
Comment by Ross — August 4, 2009 @ 3:48 pm
Ross,
Yes, that’s indeed true. I have some addititional posts about it in the pipeline.
However, .NET solves many of the issues and shortcomings with COM but at the same it creates new issues.
Kind regards,
Dennis
Comment by Dennis Wallentin — August 4, 2009 @ 6:45 pm
Hi all
See also this site
http://vbnet.mvps.org/
Comment by Ron de Bruin — August 4, 2009 @ 7:18 pm
Ron,
Thanks for the link and I believe it’s the following page You refer to when it comes to VBA and classic VB:
http://vbnet.mvps.org/index.html?code/internet/internetcheckconnection.htm
Kind regards,
Dennis
Comment by Dennis Wallentin — August 10, 2009 @ 4:48 pm