Solved

Getting Wireless Connection Name Through VBA

Posted on 2014-01-28
4
2,170 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 51

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 27

Accepted Solution

by:
MacroShadow earned 500 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 47

Expert Comment

by:Dale Fye (Access MVP)
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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Suggested Solutions

In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
After creating this article (http://www.experts-exchange.com/articles/23699/Setup-Mikrotik-routers-with-OSPF.html), I decided to make a video (no audio) to show you how to configure the routers and run some trace routes and pings between the 7 sites…

751 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