?
Solved

checking for vpn correctly in vba

Posted on 2014-01-13
2
Medium Priority
?
1,487 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 43

Accepted Solution

by:
Saqib Husain, Syed earned 2000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
This article describes a serious pitfall that can happen when deleting shapes using VBA.
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 will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

764 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