Solved

checking for vpn correctly in vba

Posted on 2014-01-13
2
1,174 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

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

Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…

707 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

13 Experts available now in Live!

Get 1:1 Help Now