PDA

View Full Version : Outlook VBA detect network adapter being used



pipopau
06-28-2011, 10:57 PM
I want to be able to add or remove a store based on the the type of connection to the Mail Server. Some user can either be connected to the Head Office subnet or connect to the mail servers via wireless broadband modems. I want to either Add or Remove Outlook pst files based on there connection type.

I have found a Reference "Network List 1.0 Type Library" and I think this may help in determining what network adapter is used to make the network connection.

I was hoping someone may be able to provide some VBA examples on how this reference works.

JP2112
06-29-2011, 06:59 PM
I think you might be able to use WMI for this. The Win32_NetworkConnection Class (http://msdn.microsoft.com/en-us/library/aa394220(v=VS.85).aspx) provides a property (ConnectionState) for determining if a given network connection is active.

I have some sample VBA code that can help you iterate through the collection and determine the connection state: http://www.codeforexcelandoutlook.com/vba/using-wmi-services-in-vba/

pipopau
07-04-2011, 09:50 PM
Thank you some very useful information but I can't see any WMi reference that tells me which adapter was used to connect to the network.