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
Solved

Getting Wireless Connection Name Through VBA

Posted on 2014-01-28
4
2,079 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 50

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

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
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…

860 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