+ Reply to Thread
Results 1 to 28 of 28

Get Data from wireless networks available to me

Hybrid View

  1. #1
    Valued Forum Contributor
    Join Date
    11-27-2011
    Location
    usa
    MS-Off Ver
    Excel 2007, Excel 365
    Posts
    495

    Get Data from wireless networks available to me

    I have decided to post this code here because the OP that it was originally written for has not responded back.

    This code, I hope, is an open source project that I hope many coders will contribute to make it even better than what I have come up with thus far.

    The code I have thus far:
    Takes the data received from a cmd prompt window command of 'netsh wlan show networks mode=BSSID' and saves much of the data received into an array and at the end it displays the array data to a sheet.

    The data gathered from that will display the SSID Name, Signal level, Band used, Channel used, Radio type, Mac Address, Authorization Algorithm, Encryption, & NetworkType.

    I am hoping that with the code I am originally providing, people will chime in with how to add additional data for each of the available WIFI networks.


    Ok, now on to the code that I am providing for starters ... I will have to post this over two different posts due to the limitations here on this site

    Part 1 of code...

    Option Explicit
    '
        #If VBA7 Then
                    Declare PtrSafe Function SetCursorPos Lib "user32" (ByVal x As Long, ByVal y As Long) As Long
                    Declare PtrSafe Function CloseClipboard Lib "user32" () As LongPtr
                    Declare PtrSafe Function EmptyClipboard Lib "user32" () As LongPtr
            Private Declare PtrSafe Function OpenClipboard Lib "user32" (ByVal hwnd As LongPtr) As LongPtr
            Private Declare PtrSafe Sub mouse_event Lib "user32" (ByVal dwFlags As Long, ByVal dx As Long, _
                        ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As LongPtr)
        #Else
                    Declare Function SetCursorPos Lib "user32" (ByVal x As Long, ByVal y As Long) As Long
                    Declare Function CloseClipboard Lib "user32" () As Long
                    Declare Function EmptyClipboard Lib "user32" () As Long
            Private Declare Function OpenClipboard Lib "user32" (ByVal hwnd As Long) As Long
            Private Declare Sub mouse_event Lib "user32" (ByVal dwFlags As Long, ByVal dx As Long, _
                        ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long)
        #End If
    '
        Public Const MOUSEEVENTF_LEFTDOWN = &H2
    
    
    Sub GetAvailableWifiNetworksInfo()
    '
        Dim ArrayRow                            As Long
        Dim IncrementalEndPosition              As Long, IncrementalStartPosition   As Long
        Dim AvailableWirelessNetworksData       As String
        Dim TimeToAllowWifiNetworksToRefresh    As String
        Dim HeaderArray                         As Variant, ResultArray()           As Variant
        Dim ws                                  As Worksheet
    '
        Set ws = Sheets("Sheet1")                                                           ' <--- Set this to the name of the sheet to diplay the results to
    '
    ' *************************
    ' * Refresh the WIFI list *
    ' *************************
    '
        TimeToAllowWifiNetworksToRefresh = "0:00:05"                                        ' <--- Set this to the amount of time to allow Wifi Networks To Refresh
    '
        With CreateObject("WScript.Shell")
            .Run "%windir%\explorer.exe ms-availablenetworks:"                              ' refresh the wifi list
        End With
    '
        Application.Wait (Now + TimeValue(TimeToAllowWifiNetworksToRefresh))                ' Delay script for a certain amount of time
    '
        SetCursorPos 400, 400: mouse_event MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0                 ' Simulate a mouse click to remove the wifi list window
    '
    ' **********************************************
    ' * Gather the available WIFI connections data *
    ' **********************************************
    '
        CreateObject("WScript.Shell").Run "cmd /c netsh wlan show networks mode=BSSID" & _
                "|clip""", 0, True                                                          ' Save results of the cmdline to the clipboard
    '
        With CreateObject("New:{1C3B4210-F441-11CE-B9EA-00AA006B1A69}")
            .GetFromClipboard                                                               '   get cmdline output from clipboard
            AvailableWirelessNetworksData = .GetText(1)                                     '   Save the clipboard contents to AvailableWirelessNetworksData
        End With
    '
        OpenClipboard (0&): EmptyClipboard: CloseClipboard                                  ' Erase the contents that were saved to the clipboard
    '
    ' ******************************************
    ' * Strip the unneeded stuff from the data *
    ' ******************************************
    '
        AvailableWirelessNetworksData = Replace(Replace(Replace(AvailableWirelessNetworksData, _
                " ", ""), vbCrLf, ""), vbLf & vbLf, vbLf)                                   ' Remove all spaces,Line feeds, and the like from the results of the clipboard
    '
    ' ***********************************************
    ' * Initialize some variables that will be used *
    ' ***********************************************
    '
        HeaderArray = Array("SSID", "   Signal        ", "   Band        ", "   Channel        ", _
                "   Radio Type        ", "   Mac Address (BSSID)        ", _
                "   Authorization Algorithm        ", "   Encryption        ", _
                "   Network Type        ")                                                  ' Establish Header names for the columns in the sheet
    '
        ReDim ResultArray(1 To 1000, 1 To UBound(HeaderArray, 1) + 1)                       ' Establish initial dimensions of the ResultArray, we can fix them later, if need be
    '
        IncrementalEndPosition = 1                                                          ' Initialize IncrementalEndPosition value
    '
    ' **********************************************************
    ' * Start saving the gathered WIFI data to our ResultArray *
    ' **********************************************************
    '
        AvailableWirelessNetworksData = Mid$(AvailableWirelessNetworksData, _
                InStr(AvailableWirelessNetworksData, "SSID"))                               ' Find first SSID position
    '
        Do While InStr(IncrementalEndPosition, AvailableWirelessNetworksData, "SSID") > 0
            ArrayRow = ArrayRow + 1                                                         '   Increment ArrayRow
    '
    ' Save the SSID
            IncrementalStartPosition = InStr(InStr(IncrementalEndPosition, AvailableWirelessNetworksData, _
                    "SSID"), AvailableWirelessNetworksData, ":") + 1                        '   Find the start character position of the SSID in AvailableWirelessNetworksData
            IncrementalEndPosition = InStr(IncrementalStartPosition, AvailableWirelessNetworksData, _
                    "Networktype")                                                          '   Find the end character position of the SSID in AvailableWirelessNetworksData
            ResultArray(ArrayRow, 1) = Mid$(AvailableWirelessNetworksData, IncrementalStartPosition, _
                    IncrementalEndPosition - IncrementalStartPosition)                      '   Save the SSID name into the ResultArray
    '
            If ResultArray(ArrayRow, 1) = "" Then ResultArray(ArrayRow, 1) = "UnNamed"      '   If the saved SSID name = "" then set the SSID name to "UnNamed"
    '
    ' Save the Networktype
            IncrementalStartPosition = InStr(InStr(IncrementalEndPosition, AvailableWirelessNetworksData, _
                    "Networktype"), AvailableWirelessNetworksData, ":") + 1                 '   Find the start character position of the Networktype in AvailableWirelessNetworksData
            IncrementalEndPosition = InStr(IncrementalStartPosition, AvailableWirelessNetworksData, _
                    "Authentication")                                                       '   Find the end character position of the Networktype in AvailableWirelessNetworksData
            ResultArray(ArrayRow, 9) = Mid$(AvailableWirelessNetworksData, IncrementalStartPosition, _
                    IncrementalEndPosition - IncrementalStartPosition)                      '   Save the Networktype into the ResultArray
    '
    ' Save the Authentication
            IncrementalStartPosition = InStr(InStr(IncrementalEndPosition, AvailableWirelessNetworksData, _
                    "Authentication"), AvailableWirelessNetworksData, ":") + 1              '   Find the start character position of the Authentication in AvailableWirelessNetworksData
            IncrementalEndPosition = InStr(IncrementalStartPosition, AvailableWirelessNetworksData, _
                    "Encryption")                                                           '   Find the end character position of the Authentication in AvailableWirelessNetworksData
            ResultArray(ArrayRow, 7) = Mid$(AvailableWirelessNetworksData, IncrementalStartPosition, _
                    IncrementalEndPosition - IncrementalStartPosition)                      '   Save the Authentication into the ResultArray
    '
    ' Save the Encryption
            IncrementalStartPosition = InStr(InStr(IncrementalEndPosition, AvailableWirelessNetworksData, _
                    "Encryption"), AvailableWirelessNetworksData, ":") + 1                  '   Find the start character position of the Encryption in AvailableWirelessNetworksData
            IncrementalEndPosition = InStr(IncrementalStartPosition, _
                    AvailableWirelessNetworksData, "BSSID")                                 '   Find the end character position of the Encryption in AvailableWirelessNetworksData
            ResultArray(ArrayRow, 8) = Mid$(AvailableWirelessNetworksData, IncrementalStartPosition, _
                    IncrementalEndPosition - IncrementalStartPosition)                      '   Save the Encryption into the ResultArray

  2. #2
    Valued Forum Contributor
    Join Date
    11-27-2011
    Location
    usa
    MS-Off Ver
    Excel 2007, Excel 365
    Posts
    495

    Re: Get Data from wireless networks available to me

    Part 2 of code...

    '
    GetBSSIDdata:
    '
    ' Save the Mac Address (BSSID)
            IncrementalStartPosition = InStr(InStr(IncrementalEndPosition, AvailableWirelessNetworksData, _
                    "BSSID"), AvailableWirelessNetworksData, ":") + 1                       '   Find the start character position of the BSSID in AvailableWirelessNetworksData
            IncrementalEndPosition = InStr(IncrementalStartPosition, _
                    AvailableWirelessNetworksData, "Signal")                                '   Find the end character position of the BSSID in AvailableWirelessNetworksData
            ResultArray(ArrayRow, 6) = Mid$(AvailableWirelessNetworksData, IncrementalStartPosition, _
                    IncrementalEndPosition - IncrementalStartPosition)                      '   Save the BSSID into the ResultArray
    '
    ' Save the Signal level
            IncrementalStartPosition = InStr(InStr(IncrementalEndPosition, AvailableWirelessNetworksData, _
                    "Signal"), AvailableWirelessNetworksData, ":") + 1                      '   Find the start character position of the Signal in AvailableWirelessNetworksData
            IncrementalEndPosition = InStr(IncrementalStartPosition, _
                    AvailableWirelessNetworksData, "Radiotype")                             '   Find the end character position of the Signal in AvailableWirelessNetworksData
            ResultArray(ArrayRow, 2) = Mid$(AvailableWirelessNetworksData, IncrementalStartPosition, _
                    IncrementalEndPosition - IncrementalStartPosition)                      '   Save the Signal into the ResultArray
    '
    ' Save the Radiotype
            IncrementalStartPosition = InStr(InStr(IncrementalEndPosition, AvailableWirelessNetworksData, _
                    "Radiotype"), AvailableWirelessNetworksData, ":") + 1                   '   Find the start character position of the Radiotype in AvailableWirelessNetworksData
            IncrementalEndPosition = InStr(IncrementalStartPosition, _
                    AvailableWirelessNetworksData, "Band")                                  '   Find the end character position of the Radiotype in AvailableWirelessNetworksData
            ResultArray(ArrayRow, 5) = Mid$(AvailableWirelessNetworksData, IncrementalStartPosition, _
                    IncrementalEndPosition - IncrementalStartPosition)                      '   Save the Radiotype into the ResultArray
    '
    ' Save the Band
            IncrementalStartPosition = InStr(InStr(IncrementalEndPosition, AvailableWirelessNetworksData, _
                    "Band"), AvailableWirelessNetworksData, ":") + 1                        '   Find the start character position of the Band in AvailableWirelessNetworksData
            IncrementalEndPosition = InStr(IncrementalStartPosition, _
                    AvailableWirelessNetworksData, "Channel")                               '   Find the end character position of the Band in AvailableWirelessNetworksData
            ResultArray(ArrayRow, 3) = Mid$(AvailableWirelessNetworksData, IncrementalStartPosition, _
                    IncrementalEndPosition - IncrementalStartPosition)                      '   Save the Band into the ResultArray
    '
    ' Save the Channel
            IncrementalStartPosition = InStr(InStr(IncrementalEndPosition, AvailableWirelessNetworksData, _
                    "Channel"), AvailableWirelessNetworksData, ":") + 1                     '   Find the start character position of the Channel in AvailableWirelessNetworksData
    '
            If InStr(IncrementalStartPosition, AvailableWirelessNetworksData, "H") > 0 Then '   If there is data after the Channel data that starts with "H" then ...
                IncrementalEndPosition = Application.Min(InStr(IncrementalStartPosition, _
                        AvailableWirelessNetworksData, "B"), InStr(IncrementalStartPosition, _
                        AvailableWirelessNetworksData, "H"))                                '       Find the end character position of the Channel in AvailableWirelessNetworksData
            Else                                                                            '   Else ...
                IncrementalEndPosition = InStr(IncrementalStartPosition, _
                        AvailableWirelessNetworksData, "B")                                 '       Find the end character position of the Channel in AvailableWirelessNetworksData
            End If
    '
            ResultArray(ArrayRow, 4) = Mid$(AvailableWirelessNetworksData, IncrementalStartPosition, _
                    IncrementalEndPosition - IncrementalStartPosition)                      '   Save the Channel into the ResultArray
    '
    ' **************************************************
    ' * Check for additional BSSID's for the same SSID *
    ' **************************************************
    '
            IncrementalStartPosition = InStr(IncrementalEndPosition, _
                    AvailableWirelessNetworksData, "SSID")                                  '   Check for additional BSSIDs
    '
            If IncrementalStartPosition <> 0 Then                                           '   If another 'SSID' is found in AvailableWirelessNetworksData then ...
                If Mid$(AvailableWirelessNetworksData, _
                        IncrementalStartPosition - 1, 1) = "B" Then                         '       If the found 'SSID' in AvailableWirelessNetworksData is preceded by 'B" then
                    ArrayRow = ArrayRow + 1                                                 '           Increment ArrayRow
    '
                    ResultArray(ArrayRow, 1) = ResultArray(ArrayRow - 1, 1)                 '           Save the previous SSID into the next row of ResultArray
                    ResultArray(ArrayRow, 7) = ResultArray(ArrayRow - 1, 7)                 '           Save the previous Authorization into the next row of ResultArray
                    ResultArray(ArrayRow, 8) = ResultArray(ArrayRow - 1, 8)                 '           Save the previous Encryption into the next row of ResultArray
                    ResultArray(ArrayRow, 9) = ResultArray(ArrayRow - 1, 9)                 '           Save the previous Networktype into the next row of ResultArray
    '
                    GoTo GetBSSIDdata                                                       '           Jump to GetBSSIDdata
                End If
            End If
        Loop                                                                                ' Loop back
    '
    ' ************************************************
    ' * Display the final results, format data, etc. *
    ' ************************************************
    '
        ResultArray = ReDimPreserve(ResultArray, ArrayRow, UBound(HeaderArray, 1) + 1)      ' Delete any unneeded rows in the ResultArray
    '
        With ws
            .Cells(1, "A").Resize(.Cells(.Rows.Count, "A").End(xlUp).Row, _
                    UBound(HeaderArray, 1) + 1).ClearContents                               '   Clear previous results from sheet
    '
            With .Range("A1").Resize(, UBound(HeaderArray, 1) + 1)
                .Value2 = HeaderArray                                                       '       Display the HeaderArray to the sheet
                .HorizontalAlignment = xlCenter                                             '       Center the Headers horizontally in the cells
                  .VerticalAlignment = xlCenter                                             '       Center the Headers vertically in the cells
                     .Font.FontStyle = "Bold"                                               '       Bold the Headers
            End With
    '
            .Range("A2").Resize(UBound(ResultArray, 1), UBound(ResultArray, 2)) = ResultArray   ' Display the ResultArray to the sheet
    '
            .Range("B2:E" & ArrayRow + 1).HorizontalAlignment = xlCenter                    '   Center the data in columns B:E horizontally in the cells
    '
            .UsedRange.EntireColumn.AutoFit                                                 '   Autofit the used columns widths of the sheet
    '
            If .AutoFilterMode Then .AutoFilterMode = False                                 '   If there is filtered data on the sheet then remove the filter
    '
            With .Cells(1, 1).CurrentRegion
                .Cells.Sort Key1:=.Columns(2), Order1:=xlDescending, _
                        Orientation:=xlTopToBottom, Header:=xlYes                           '       Sort the data according to Signal Column B values highest to lowest
                .AutoFilter                                                                 '       add AutoFilter option to the sheet
            End With
        End With
    End Sub
    
    Public Function ReDimPreserve(ArrayNameToResize, NewRowUbound, NewColumnUbound)
    '
    ' Code inspired by Control Freak
    '
    ' Preserve Original data & LBounds & Redim both dimensions for a 2D array
    '
    ' example usage of the function:
    ' ResizedArrayName = ReDimPreserve(ArrayNameToResize,NewRowSize,NewColumnSize)
    ' ie.
    ' InputArray = ReDimPreserve(InputArray,10,20)
    '
    ' This function will keep the LBounds (Lower Bounds) of the original array.
    '
        Dim NewColumn                   As Long, NewRow                      As Long
        Dim OldColumnLbound             As Long, OldRowLbound                As Long
        Dim OldColumnUbound             As Long, OldRowUbound                As Long
        Dim NewResizedArray()           As Variant
    '
        ReDimPreserve = False
    '
        If IsArray(ArrayNameToResize) Then                                                                      ' If the variable is an array then ...
               OldRowLbound = LBound(ArrayNameToResize, 1)                                                      '   Save the original row Lbound to OldRowLbound
            OldColumnLbound = LBound(ArrayNameToResize, 2)                                                      '   Save the original column Lbound to OldColumnLbound
    '
            ReDim NewResizedArray(OldRowLbound To NewRowUbound, OldColumnLbound To NewColumnUbound)             '   Create a New 2D Array with same Lbounds as the original array
    '
            OldRowUbound = UBound(ArrayNameToResize, 1)                                                         '   Save row Ubound of original array
            OldColumnUbound = UBound(ArrayNameToResize, 2)                                                      '   Save column Ubound of original array
    '
            For NewRow = OldRowLbound To NewRowUbound                                                           '   Loop through rows of original array
                For NewColumn = OldColumnLbound To NewColumnUbound                                              '       Loop through columns of original array
                    If OldRowUbound >= NewRow And OldColumnUbound >= NewColumn Then                             '           If more data to copy then ...
                        NewResizedArray(NewRow, NewColumn) = ArrayNameToResize(NewRow, NewColumn)               '               Append rows/columns to NewResizedArray
                    End If
                Next                                                                                            '       Loop back
            Next                                                                                                '   Loop back
    '
            Erase ArrayNameToResize                                                                             '   Free up the memory the Original array was taking
    '
            If IsArray(NewResizedArray) Then ReDimPreserve = NewResizedArray
        End If
    End Function

    Please post your comments, suggestions, concerns, etc.

  3. #3
    Valued Forum Contributor
    Join Date
    11-27-2011
    Location
    usa
    MS-Off Ver
    Excel 2007, Excel 365
    Posts
    495

    Re: Get Data from wireless networks available to me

    Here is the original code saved as a file.
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    04-16-2013
    Location
    Irving, Texas
    MS-Off Ver
    Excel 95 through Excel 2013
    Posts
    22

    Re: Get Data from wireless networks available to me

    I'd post a screen shot but it won't let me attach any pictures...

    Throws a Run-time error '5':
    Invalid procedure call or argument

    Here's the offending line:
            ResultArray(ArrayRow, 5) = Mid$(AvailableWirelessNetworksData, IncrementalStartPosition, _
                    IncrementalEndPosition - IncrementalStartPosition)                      '   Save the Radiotype into the ResultArray


    Hovering over the variable reveals...

    ArrayRow = 1
    AvailableWirelessNetworksData = (shows a long name of a wireless network being detected)
    IncrementalStartPosition = 139
    IncrementalEndPosition = 0

    This suggests it's not picking up a valid "IncrementalEndPosition' because the equation IncrementalEndPosition {0} - IncrementalStartPosition {139} would result in a negative number and the length portion of the Mid$ function can't be negative.

  5. #5
    Registered User
    Join Date
    04-16-2013
    Location
    Irving, Texas
    MS-Off Ver
    Excel 95 through Excel 2013
    Posts
    22

    Re: Get Data from wireless networks available to me

    I decided to step through the code and actually it throws an earlier error

    explorer.exe
    There is no program associated to perform the requested action. Please install a program or, if one is already installed, create an association in the Default Programs control panel.
    Here's the offending line:
        With CreateObject("WScript.Shell")
            .Run "%windir%\explorer.exe ms-availablenetworks:"                              ' refresh the wifi list
        End With

  6. #6
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2505 (Windows 11 Home 24H2 64-bit)
    Posts
    91,211

    Re: Get Data from wireless networks available to me

    Moved to the appropriate forum section. Thanks for sharing.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

  7. #7
    Valued Forum Contributor
    Join Date
    11-27-2011
    Location
    usa
    MS-Off Ver
    Excel 2007, Excel 365
    Posts
    495

    Re: Get Data from wireless networks available to me

    Which version of windows & which version of excel are you using?

  8. #8
    Registered User
    Join Date
    04-16-2013
    Location
    Irving, Texas
    MS-Off Ver
    Excel 95 through Excel 2013
    Posts
    22

    Re: Get Data from wireless networks available to me

    Windows 7 x64 and Office 2010 x64

  9. #9
    Valued Forum Contributor
    Join Date
    11-27-2011
    Location
    usa
    MS-Off Ver
    Excel 2007, Excel 365
    Posts
    495

    Re: Get Data from wireless networks available to me

    Do you have a newer version of Office to test with?

  10. #10
    Registered User
    Join Date
    04-16-2013
    Location
    Irving, Texas
    MS-Off Ver
    Excel 95 through Excel 2013
    Posts
    22

    Re: Get Data from wireless networks available to me

    I have 2013 on my Windows 10 laptop but that's not where the issue is.
    But I can certainly test it.

    stand by...

  11. #11
    Registered User
    Join Date
    04-16-2013
    Location
    Irving, Texas
    MS-Off Ver
    Excel 95 through Excel 2013
    Posts
    22

    Re: Get Data from wireless networks available to me

    OK, well this is unpleasant...

    I could see it was running (opened Windows Wi-Fi from the taskbar) but then it threw another invalid procedure call and now the only think work is this browser window.
    I can ALT-TAB through the applications but can't do anything in them.
    Suspect explorer.exe is hung on something...

  12. #12
    Valued Forum Contributor
    Join Date
    11-27-2011
    Location
    usa
    MS-Off Ver
    Excel 2007, Excel 365
    Posts
    495

    Re: Get Data from wireless networks available to me

    Please try a reboot on that machine and test it again.

  13. #13
    Registered User
    Join Date
    04-16-2013
    Location
    Irving, Texas
    MS-Off Ver
    Excel 95 through Excel 2013
    Posts
    22

    Re: Get Data from wireless networks available to me

    OK, that was odd.

    Mouse moved but had no effect.
    Only keyboard was working

    OK, finally back to the VBE and it threw the error on this box at the same line as the other. In the Save the RadioType section on the ResultArray line.

  14. #14
    Registered User
    Join Date
    04-16-2013
    Location
    Irving, Texas
    MS-Off Ver
    Excel 95 through Excel 2013
    Posts
    22

    Re: Get Data from wireless networks available to me

    lol, mouse still only works in this browser window...

  15. #15
    Valued Forum Contributor
    Join Date
    11-27-2011
    Location
    usa
    MS-Off Ver
    Excel 2007, Excel 365
    Posts
    495

    Re: Get Data from wireless networks available to me

    The code has been tested several times on my end successfully, so if you can try rebooting the windows 10 computer and try it again?

  16. #16
    Valued Forum Contributor
    Join Date
    11-27-2011
    Location
    usa
    MS-Off Ver
    Excel 2007, Excel 365
    Posts
    495

    Re: Get Data from wireless networks available to me

    In the mean time, I am creating a new version that will actually work on Excel 2007.

  17. #17
    Registered User
    Join Date
    04-16-2013
    Location
    Irving, Texas
    MS-Off Ver
    Excel 95 through Excel 2013
    Posts
    22

    Re: Get Data from wireless networks available to me

    ok, well this has been interesting but I have to restart again...

    I'm left-handed so it dawned on me that my alternate buttons might be causing some issues with your code.
    So, the 2nd time I restarted, I switched the buttons back to wrong-handed and tested it again.

    It does NOT throw the initial 'explorer.exe' error.

    However, it DOES still throw the Run-time error on the ResultArray step of the 'Save the Radiotype' section.
    Somehow, the 'IncrementalEndPosition' variable winds up being less than the 'IncrementalStartPosition' variable.
    This results in a negative result for the [Lebgth] element of the 'Mid' function on that line.

    I'm unfamiliar, (so far) with the contents of the string you're working with but it seems somehow the math gets negative on the length ofthe string.

    EDIT: The above references running on Win 10 with Office 2013 (the W540 and not problem PC).

  18. #18
    Valued Forum Contributor
    Join Date
    11-27-2011
    Location
    usa
    MS-Off Ver
    Excel 2007, Excel 365
    Posts
    495

    Re: Get Data from wireless networks available to me

    Your buttons should have nothing to do with the code.

    The following attachment has been tested in excel 2013, It doesn't use that initial code that was throwing the error for you, try it out and see if it works for you:
    Attached Files Attached Files

  19. #19
    Registered User
    Join Date
    04-16-2013
    Location
    Irving, Texas
    MS-Off Ver
    Excel 95 through Excel 2013
    Posts
    22

    Re: Get Data from wireless networks available to me

    Yeah, the problem, or at least the problem which is currently hanging me up is that variable looking for a string that isn't there.
    InStr(IncrementalStartPosition, AvailableWirelessNetworksData, "Band")
    This resolves to zero (0) because "Band" is not in the string.

    There error happens with both files on the same line of code.

  20. #20
    Registered User
    Join Date
    04-16-2013
    Location
    Irving, Texas
    MS-Off Ver
    Excel 95 through Excel 2013
    Posts
    22

    Re: Get Data from wireless networks available to me

    OK, sorry for the lapse.
    I was looking at the code and the string but had a distraction.

    In your original code, your variable 'IncrementalEndPosition' tries to get a value from an InStr that's looking for the string "Band"
    But the word "Band" isn't in the string, anywhere.
    So it naturally resolves to 0 (zero).

    I've downloaded the replacement file and will test it now...

  21. #21
    Valued Forum Contributor
    Join Date
    11-27-2011
    Location
    usa
    MS-Off Ver
    Excel 2007, Excel 365
    Posts
    495

    Re: Get Data from wireless networks available to me

    Do you know how to open up a Command prompt window as administrator?

  22. #22
    Registered User
    Join Date
    04-16-2013
    Location
    Irving, Texas
    MS-Off Ver
    Excel 95 through Excel 2013
    Posts
    22

    Re: Get Data from wireless networks available to me

    So I edited the line for the 'IncrementalEndPosition' to look for "Channel" instead of "Band"

    Then I remarked out the whole section for capturing the "Band" value.

    And it ran fine from there,
    The "Band" column in the table is empty.

    Yes, I'm able to open a command prompt as admin

  23. #23
    Valued Forum Contributor
    Join Date
    11-27-2011
    Location
    usa
    MS-Off Ver
    Excel 2007, Excel 365
    Posts
    495

    Re: Get Data from wireless networks available to me

    Ok, DISCONNECT from any WIFI connection that you are able to connect to.

    Then open up a Command Prompt window as Admin
    then enter the following command:

    netsh wlan show networks mode=BSSID

    Then copy/paste the results that you get here.

  24. #24
    Registered User
    Join Date
    04-16-2013
    Location
    Irving, Texas
    MS-Off Ver
    Excel 95 through Excel 2013
    Posts
    22

    Re: Get Data from wireless networks available to me

    Interface name : Wi-Fi
    There are 21 networks currently visible.

    SSID 1 : ATTAEM9WFi
    Network type : Infrastructure
    Authentication : WPA2-Personal
    Encryption : CCMP
    BSSID 1 : f8:2d:c0:da:7a:70
    Signal : 93%
    Radio type : 802.11n
    Channel : 10
    Basic rates (Mbps) : 6.5 16 19.5 117
    Other rates (Mbps) : 18 19.5 24 36 39 48 54 156
    BSSID 2 : e6:2d:c0:da:7a:73
    Signal : 76%
    Radio type : 802.11ac
    Channel : 157
    Basic rates (Mbps) : 58.5
    Other rates (Mbps) : 12 18 24 36 48 54 526.5

    SSID 2 : Middle-Earth-5GHz
    Network type : Infrastructure
    Authentication : WPA2-Personal
    Encryption : CCMP
    BSSID 1 : 28:74:f5:bc:64:b8
    Signal : 73%
    Radio type : 802.11ax
    Channel : 48
    Basic rates (Mbps) : 24 58.5
    Other rates (Mbps) : 12 18 36 48 54 526.5
    BSSID 2 : 28:74:f5:bc:64:bc
    Signal : 75%
    Radio type : 802.11ax
    Channel : 149
    Basic rates (Mbps) : 24 58.5
    Other rates (Mbps) : 12 18 36 48 54 526.5

    SSID 3 : ATT3hyr2ex
    Network type : Infrastructure
    Authentication : WPA2-Personal
    Encryption : CCMP
    BSSID 1 : 78:6a:1f:c7:73:e0
    Signal : 65%
    Radio type : 802.11n
    Channel : 5
    Basic rates (Mbps) : 6.5 16 19.5 117
    Other rates (Mbps) : 18 19.5 24 36 39 48 54 156
    BSSID 2 : 66:6a:1f:c7:73:e3
    Signal : 48%
    Radio type : 802.11ac
    Channel : 40
    Basic rates (Mbps) : 58.5
    Other rates (Mbps) : 12 18 24 36 48 54 526.5

    SSID 4 :
    Network type : Infrastructure
    Authentication : WPA2-Personal
    Encryption : CCMP
    BSSID 1 : f8:2d:c0:da:7a:73
    Signal : 76%
    Radio type : 802.11ac
    Channel : 157
    Basic rates (Mbps) : 58.5
    Other rates (Mbps) : 12 18 24 36 48 54 526.5

    SSID 5 : DIRECT-EC-HP DeskJet 2700 series
    Network type : Infrastructure
    Authentication : WPA2-Personal
    Encryption : CCMP
    BSSID 1 : f8:0d:ac:84:a6:ed
    Signal : 61%
    Radio type : 802.11n
    Channel : 1
    Basic rates (Mbps) : 39
    Other rates (Mbps) : 18 19.5 24 36 48 54 156

    SSID 6 : ATTN3qsitC
    Network type : Infrastructure
    Authentication : WPA2-Personal
    Encryption : CCMP
    BSSID 1 : e0:1f:2b:94:25:8c
    Signal : 31%
    Radio type : 802.11ax
    Channel : 112
    Basic rates (Mbps) : 24 58.5
    Other rates (Mbps) : 12 18 36 48 54 526.5
    BSSID 2 : e0:1f:2b:94:25:88
    Signal : 41%
    Radio type : 802.11ax
    Channel : 48
    Basic rates (Mbps) : 24 58.5
    Other rates (Mbps) : 12 18 36 48 54 526.5
    BSSID 3 : e0:1f:2b:94:25:84
    Signal : 65%
    Radio type : 802.11n
    Channel : 6
    Basic rates (Mbps) : 6.5 16 19.5 117
    Other rates (Mbps) : 18 19.5 24 36 39 48 54 156

    SSID 7 : ATTHiJwT8d
    Network type : Infrastructure
    Authentication : WPA2-Personal
    Encryption : CCMP
    BSSID 1 : d0:fc:d0:b0:c1:c4
    Signal : 21%
    Radio type : 802.11n
    Channel : 11
    Basic rates (Mbps) : 6.5 16 19.5 117
    Other rates (Mbps) : 18 19.5 24 36 39 48 54 156

    SSID 8 : B speaker.o,
    Network type : Infrastructure
    Authentication : Open
    Encryption : None
    BSSID 1 : fa:8f:ca:7c:02:7c
    Signal : 36%
    Radio type : 802.11n
    Channel : 6
    Basic rates (Mbps) : 6.5 16 19.5 117
    Other rates (Mbps) : 18 19.5 24 36 39 48 54 156

    SSID 9 : ATTQ4yEsys
    Network type : Infrastructure
    Authentication : WPA2-Personal
    Encryption : CCMP
    BSSID 1 : 18:b8:1f:04:1a:90
    Signal : 48%
    Radio type : 802.11n
    Channel : 2
    Basic rates (Mbps) : 6.5 16 19.5 117
    Other rates (Mbps) : 18 19.5 24 36 39 48 54 156
    BSSID 2 : 06:b8:1f:04:1a:93
    Signal : 21%
    Radio type : 802.11ac
    Channel : 149
    Basic rates (Mbps) : 58.5
    Other rates (Mbps) : 12 18 24 36 48 54 526.5

    SSID 10 : Middle-Earth-2.4GHz
    Network type : Infrastructure
    Authentication : WPA2-Personal
    Encryption : CCMP
    BSSID 1 : 28:74:f5:bc:64:b4
    Signal : 88%
    Radio type : 802.11n
    Channel : 11
    Basic rates (Mbps) : 6.5 16 19.5 117
    Other rates (Mbps) : 18 19.5 24 36 39 48 54 156

    SSID 11 : ATTvMmrm7i
    Network type : Infrastructure
    Authentication : WPA2-Personal
    Encryption : CCMP
    BSSID 1 : f4:17:b8:dc:a1:a8
    Signal : 25%
    Radio type : 802.11ax
    Channel : 153
    Basic rates (Mbps) : 12 24 58.5
    Other rates (Mbps) : 18 36 48 54 526.5
    BSSID 2 : e6:ae:34:2d:4d:a3
    Signal : 58%
    Radio type : 802.11ac
    Channel : 153
    Basic rates (Mbps) : 58.5
    Other rates (Mbps) : 12 18 24 36 48 54 526.5
    BSSID 3 : f4:17:b8:dc:a1:a7
    Signal : 38%
    Radio type : 802.11ax
    Channel : 52
    Basic rates (Mbps) : 24 58.5
    Other rates (Mbps) : 12 18 36 48 54 526.5
    BSSID 4 : fc:ae:34:2d:4d:a0
    Signal : 71%
    Radio type : 802.11n
    Channel : 3
    Basic rates (Mbps) : 6.5 16 19.5 117
    Other rates (Mbps) : 18 19.5 24 36 39 48 54 156
    BSSID 5 : f4:17:b8:dc:a1:a6
    Signal : 53%
    Radio type : 802.11n
    Channel : 6
    Basic rates (Mbps) : 6.5 16 19.5 117
    Other rates (Mbps) : 18 19.5 24 36 39 48 54 156

    SSID 12 : ATTWIxaZur
    Network type : Infrastructure
    Authentication : WPA2-Personal
    Encryption : CCMP
    BSSID 1 : d0:fc:d0:c2:eb:dc
    Signal : 20%
    Radio type : 802.11ax
    Channel : 132
    Basic rates (Mbps) : 24 58.5
    Other rates (Mbps) : 12 18 36 48 54 526.5
    BSSID 2 : d0:fc:d0:c2:eb:d8
    Signal : 20%
    Radio type : 802.11ax
    Channel : 52
    Basic rates (Mbps) : 24 58.5
    Other rates (Mbps) : 12 18 36 48 54 526.5

    SSID 13 : DivyaB
    Network type : Infrastructure
    Authentication : WPA3-Personal
    Encryption : CCMP
    BSSID 1 : c4:eb:42:84:3a:b6
    Signal : 30%
    Radio type : 802.11ax
    Channel : 1
    Basic rates (Mbps) : 6.5 16 19.5 117
    Other rates (Mbps) : 18 19.5 24 36 39 48 54 156

    SSID 14 : ATT2Y3DAtc
    Network type : Infrastructure
    Authentication : WPA2-Personal
    Encryption : CCMP
    BSSID 1 : 0c:7c:28:ac:4e:94
    Signal : 13%
    Radio type : 802.11ax
    Channel : 161
    Basic rates (Mbps) : 24 58.5
    Other rates (Mbps) : 12 18 36 48 54 526.5

    SSID 15 : ATTJ7BE57i
    Network type : Infrastructure
    Authentication : WPA2-Personal
    Encryption : CCMP
    BSSID 1 : 60:d2:48:3b:c5:30
    Signal : 46%
    Radio type : 802.11n
    Channel : 5
    Basic rates (Mbps) : 6.5 16 19.5 117
    Other rates (Mbps) : 18 19.5 24 36 39 48 54 156

    SSID 16 : Middle-Earth-Guest
    Network type : Infrastructure
    Authentication : WPA2-Personal
    Encryption : CCMP
    BSSID 1 : 28:74:f5:bc:64:b5
    Signal : 88%
    Radio type : 802.11n
    Channel : 11
    Basic rates (Mbps) : 6.5 16 19.5 117
    Other rates (Mbps) : 18 19.5 24 36 39 48 54 156

    SSID 17 : WASHINGTON-1144
    Network type : Infrastructure
    Authentication : WPA3-Personal
    Encryption : CCMP
    BSSID 1 : b0:fc:88:d3:c9:76
    Signal : 23%
    Radio type : 802.11ax
    Channel : 11
    Basic rates (Mbps) : 6.5 16 19.5 117
    Other rates (Mbps) : 18 19.5 24 36 39 48 54 156

    SSID 18 : ATTUixfQ5J
    Network type : Infrastructure
    Authentication : WPA2-Personal
    Encryption : CCMP
    BSSID 1 : 80:ab:4d:91:3b:74
    Signal : 28%
    Radio type : 802.11n
    Channel : 1
    Basic rates (Mbps) : 24 39 156
    Other rates (Mbps) : 18 19.5 36 48 54

    SSID 19 : Williamson1966
    Network type : Infrastructure
    Authentication : WPA2-Personal
    Encryption : CCMP
    BSSID 1 : 6c:4b:b4:83:ae:f4
    Signal : 25%
    Radio type : 802.11n
    Channel : 6
    Basic rates (Mbps) : 6.5 16 19.5 117
    Other rates (Mbps) : 18 19.5 24 36 39 48 54 156

    SSID 20 : ATTuVq4NuI
    Network type : Infrastructure
    Authentication : WPA2-Personal
    Encryption : CCMP
    BSSID 1 : 6c:4b:b4:2e:46:64
    Signal : 31%
    Radio type : 802.11n
    Channel : 6
    Basic rates (Mbps) : 6.5 16 19.5 117
    Other rates (Mbps) : 18 19.5 24 36 39 48 54 156

    SSID 21 : Cano
    Network type : Infrastructure
    Authentication : WPA2-Personal
    Encryption : CCMP
    BSSID 1 : e0:1f:2b:35:38:c4
    Signal : 26%
    Radio type : 802.11n
    Channel : 1
    Basic rates (Mbps) : 6.5 16 19.5 117
    Other rates (Mbps) : 18 19.5 24 36 39 48 54 156

  25. #25
    Registered User
    Join Date
    04-16-2013
    Location
    Irving, Texas
    MS-Off Ver
    Excel 95 through Excel 2013
    Posts
    22

    Re: Get Data from wireless networks available to me

    This is run on the W540.

    These are my SSIDs:
    SSID 2 : Middle-Earth-5GHz
    SSID 10 : Middle-Earth-2.4GHz
    SSID 16 : Middle-Earth-Guest

    As a side note, notice there is no "Band" category between "Radio Type" and "Channel."

  26. #26
    Registered User
    Join Date
    04-16-2013
    Location
    Irving, Texas
    MS-Off Ver
    Excel 95 through Excel 2013
    Posts
    22

    Re: Get Data from wireless networks available to me

    I'll run this on the subject laptop (T520) a little later as it is currently in use elsewhere.

  27. #27
    Valued Forum Contributor
    Join Date
    11-27-2011
    Location
    usa
    MS-Off Ver
    Excel 2007, Excel 365
    Posts
    495

    Re: Get Data from wireless networks available to me

    Let me know when you are available to test again.

  28. #28
    Registered User
    Join Date
    12-23-2023
    Location
    europe
    MS-Off Ver
    365
    Posts
    2

    Re: Get Data from wireless networks available to me

    thank you for the code

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Add Networks Days Formula to the attached
    By Moggzy in forum Excel General
    Replies: 1
    Last Post: 03-23-2022, 08:10 AM
  2. Shift + F8 not working on my wireless keyboard
    By cfreeman114 in forum Excel General
    Replies: 0
    Last Post: 06-15-2017, 02:59 PM
  3. Auto Numbering and Saving for users on different computers & networks
    By robbyb05 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-18-2015, 10:51 AM
  4. Windows 7 :Remote Desktop Home PC from My Wireless
    By Mordred in forum Microsoft Windows Help
    Replies: 19
    Last Post: 07-23-2012, 12:06 AM
  5. Neural Networks to Check BOMs?
    By ahartman in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-02-2009, 03:15 PM
  6. [SOLVED] wireless connection needs constant repair
    By opxidaea in forum Excel General
    Replies: 2
    Last Post: 11-01-2005, 11:05 AM
  7. new excel files not saving across wireless network
    By fryb53 in forum Excel General
    Replies: 1
    Last Post: 05-15-2005, 10:06 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1