Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Getting Wireless Connection Name Through VBA

Posted on 2014-01-28
4
Medium Priority
?
2,436 Views
Last Modified: 2014-02-26
Is there any way for us to get the SSID of the Wifi or the name of the Local Area Network we are currently connected to?

Basically, I want to detect the name of the active connection, e.g. if it is the office network, then allow the script to resume, if it is the home network, or a public wifi etc, do not resume with script execution or provide an option to connect to a VPN of the office network.
0
Comment
Question by:jb702
4 Comments
 
LVL 53

Expert Comment

by:Rgonzo1971
ID: 39816994
Hi,

maybe

LAN_Id = Environ("ComputerName")
UDomain = Environ("UserDomain")
Debug.Print UDomain
Debug.Print LAN_Id

Open in new window

Regards
0
 
LVL 28

Accepted Solution

by:
MacroShadow earned 2000 total points
ID: 39817133
Function GetNameOfActiveConnection() As String

    Dim strComputer As String
    Dim objWMIService As Object, colLAN As Object, colWiFi As Object, objWifi As Object, objLAN As Object

    strComputer = "."
    Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
    Set colLAN = objWMIService.ExecQuery("Select * From Win32_NetworkAdapter Where NetConnectionID like 'Local Area Connection' and PhysicalAdapter='True'")
    Set colWiFi = objWMIService.ExecQuery("Select * From Win32_NetworkAdapter Where NetConnectionID =" & "'" & GetWirlessName & "'" & "and PhysicalAdapter='True' ")

    For Each objWifi In colWiFi
        If objWifi.Netconnectionstatus = 2 Then
            GetNameOfActiveConnection = objWifi.Name
        End If
    Next

    For Each objLAN In colLAN
        If objLAN.Netconnectionstatus = 2 Then
            GetNameOfActiveConnection = objLAN.Name
        End If
    Next

End Function

Open in new window

0
 
LVL 49

Expert Comment

by:Dale Fye
ID: 39817461
Personally, I would recommend against using Access over a wireless connection, especially from a laptop or tablet that you are moving throughout your environment.  The potential for broken connections (and therefore data corruption) is much higher when using Access over wireless.

Additionally, wireless connections are significantly slower than wired and your application is likely to function extremely slowly.

Finally, if you seriously need this functionality, recommend you move your back-end to SQL Server or SQL Server express.
0
 

Author Closing Comment

by:jb702
ID: 39890882
Thank you
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
Make the most of your online learning experience.
Loops Section Overview
Screencast - Getting to Know the Pipeline

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question