Solved Test Wifi signal Strength using Excel VBA

June 4, 2013 at 09:58:53
Specs: Windows 7
Hi there,

I've built an app in VBA (Excel 2007) which is a portable application. It can work in a number of locations and will occasionally need to transfer files to a cloud server. I can test to see if a wifi signal is available or not. The problem is I can't tell how good the signal is and this sometimes fails if the strength is low.

Is there any vba code which can determine if the signal is low, good or excellent?

Again, thanks in anticipation.


See More: Test Wifi signal Strength using Excel VBA

Report •


✔ Best Answer
June 4, 2013 at 12:49:38
If IsNull(oRetStatus.StatusCode) Or oRetStatus.StatusCode <> 0 Then
    sPing = False
Else
    sPing = True
End If
Note: This can be rewritten as:
sPing = oRetStatus.StatusCode = 0 And Not IsNull(oRetStatus.StatusCode)

Function sPing(sHost) As String
Also, you're returning a Boolean, so you should probably fix your function deceleration.


Time for good news / bad news.
Good: I found a WMI class you might be able to use: http://blogs.technet.com/b/heyscrip...

Bad: This WMI class is not publicly documented, so its implementation is hit and miss. If you need this to work on a number of machines, you're left with the Windows API.

How To Ask Questions The Smart Way



#1
June 4, 2013 at 10:56:48
re: I can test to see if a wifi signal is available or not.

How are you performing that test?

Click Here Before Posting Data or VBA Code ---> How To Post Data or Code.


Report •

#2
June 4, 2013 at 11:44:55
This is either going to be great, or it's going to be terrible. I'm betting on terrible, seeing as we're probably dealing with system calls and VBA.

How To Ask Questions The Smart Way


Report •

#3
June 4, 2013 at 11:57:07
Hi DarbyDad03, here's the sub:-
Sub DoPing()
nPing = sPing("www.google.co.uk")
End Sub

here's the function which tests for a signal

Function sPing(sHost) As String
    Dim oPing As Object, oRetStatus As Object
    Set oPing = GetObject("winmgmts:{impersonationLevel=impersonate}").ExecQuery _
      ("select * from Win32_PingStatus where address = '" & sHost & "'")
    For Each oRetStatus In oPing
        If IsNull(oRetStatus.StatusCode) Or oRetStatus.StatusCode <> 0 Then
            sPing = False
        Else
            sPing = True
        End If
    Next
End Function


BTW, I've declared the variables in Option Explicit


Report •

Related Solutions

#4
June 4, 2013 at 11:58:37
LOL... Thanks Razor2.3

I'm optimistic or maybe just desparate?


Report •

#5
June 4, 2013 at 12:49:38
✔ Best Answer
If IsNull(oRetStatus.StatusCode) Or oRetStatus.StatusCode <> 0 Then
    sPing = False
Else
    sPing = True
End If
Note: This can be rewritten as:
sPing = oRetStatus.StatusCode = 0 And Not IsNull(oRetStatus.StatusCode)

Function sPing(sHost) As String
Also, you're returning a Boolean, so you should probably fix your function deceleration.


Time for good news / bad news.
Good: I found a WMI class you might be able to use: http://blogs.technet.com/b/heyscrip...

Bad: This WMI class is not publicly documented, so its implementation is hit and miss. If you need this to work on a number of machines, you're left with the Windows API.

How To Ask Questions The Smart Way


Report •

#6
June 4, 2013 at 13:15:46
Thanks Razor2.3 I've looked at the blog and it looks like it has potential. I'm running on Windows 7 and it looks like it's having difficulty with the objItem. Will work on this and get back.

Thanks


Report •


Ask Question