Solved

Getting Wireless Connection Name Through VBA

Posted on 2014-01-28
4
1,879 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 48

Expert Comment

by:Rgonzo1971
Comment Utility
Hi,

maybe

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

Open in new window

Regards
0
 
LVL 26

Accepted Solution

by:
MacroShadow earned 500 total points
Comment Utility
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)
Comment Utility
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
Comment Utility
Thank you
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This is the first one of a series of articles I’ll be writing to address technical issues that are always referred to as network problems. The network boundaries have changed, therefore having an understanding of how each piece in the network  puzzl…
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

771 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now