Solved

checking for vpn correctly in vba

Posted on 2014-01-13
2
1,365 Views
Last Modified: 2014-01-15
excel 2010 vba:


'Please check description of your VPN Connection by running command "ipconfig /all" on command-line.

    
    ' NO CELL CARD...wireless at home...vpn description
    If (InStr(objItem.Description, "AnyConnect")) Then
     IsVPNConnected = objItem.IPEnabled
    End If

  ''Branch Wireless  works
   If (InStr(objItem.Description, "Centrino")) Then
     IsVPNConnected = objItem.IPEnabled
    End If


  'Branch Ethernet hardwired works
   If (InStr(objItem.Description, "Gigabit")) Then
     IsVPNConnected = objItem.IPEnabled
    End If
  

   If (IsVPNConnected) Then
    IsVPNConnected = MsgBox("I am Connected to VPN.")
    GoTo LINE20
    
    
   Else
    IsVPNConnected = MsgBox("I am Not Connected to VPN.")
   GoTo LINE10
   
   End If

Open in new window




Just lookin to clean this if.then... code up.

Is there a better way to check for each connection ?

if any of these are true then...
 
    ' NO CELL CARD...wireless at home...vpn description
    If (InStr(objItem.Description, "AnyConnect")) Then
     IsVPNConnected = objItem.IPEnabled
    End If

  ''Branch Wireless  works
   If (InStr(objItem.Description, "Centrino")) Then
     IsVPNConnected = objItem.IPEnabled
    End If


  'Branch Ethernet hardwired works
   If (InStr(objItem.Description, "Gigabit")) Then
     IsVPNConnected = objItem.IPEnabled
    End If


 If (IsVPNConnected) Then
    IsVPNConnected = MsgBox("I am Connected to VPN.")
    GoTo LINE20
   
   
   Else
    IsVPNConnected = MsgBox("I am Not Connected to VPN.")
   GoTo LINE10

Thanks

fordraiders
0
Comment
Question by:fordraiders
2 Comments
 
LVL 43

Accepted Solution

by:
Saqib Husain, Syed earned 500 total points
ID: 39777700
Here is one

    If (InStr(objItem.Description, "AnyConnect")) Or _
        (InStr(objItem.Description, "Centrino")) Or _
        (InStr(objItem.Description, "Gigabit")) Then
     IsVPNConnected = objItem.IPEnabled
    End If
 

   If (IsVPNConnected) Then
    IsVPNConnected = MsgBox("I am Connected to VPN.")
    GoTo LINE20
   
   
   Else
    IsVPNConnected = MsgBox("I am Not Connected to VPN.")
   GoTo LINE10
   
   End If
0
 
LVL 3

Author Closing Comment

by:fordraiders
ID: 39783068
Thanks very much
0

Featured Post

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

Suggested Solutions

Introduction While answering a recent question (http:/Q_27311462.html), I created an alternative function to the Excel Concatenate() function that you might find useful.  I tested several solutions and share the results in this article as well as t…
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …

730 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