Solved

checking for vpn correctly in vba

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

828 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