I’m absolutely certain that this has come up before but my complete inability to operate a search engine has resulted in a null score.
How do I work out in vba whether my laptop is dialled up or not?
I have a data manipulation sub in excel that chunders data around for a bit and then prints the resultant files; which is fine at work but if I’m running from home I don’t want the print bit to work. I think I could use on error resume next but I’ve got the same problem with other stuff, so wouldn’t mind treating the cause as opposed to the symptoms.
Obviously, I could have two cover subs
a) Sub RunFromHome
Sub RunFromWork
which then pass printer status to the main routine but a) I’m lazy and I’m curious
I’ve tried the following
Option Explicit
Declare Function GetSystemMetrics Lib “user32.dll” (ByVal nIndex As Long) As Long
Sub GetNetworkInfo()
Const SM_NETWORK = 63
Dim CheckNetWork As Long ‘ Check if network is presented.
‘ Display whether the system has a network connection installed.
CheckNetWork = GetSystemMetrics(SM_NETWORK)
If (CheckNetWork And &H1) = &H1 Then ‘ check only the information bit
MsgBox “A network is configured to be used by Windows.”
Else
MsgBox “No network is currently configured.”
End If
End Sub
but when I’m at home I get the first msgbox – but I think the key here is the word “configured” ?
I am, as ever, as confused as a confused thing. Any help would result in a virtual beer as long as I can find the link!
Brooke