Solved

Get VPN or Internet Access as a MsgBox - Excel Macro Code

Posted on 2016-09-18
  • Windows Networking
  • VBA
  • Microsoft Office
  • Microsoft Excel
  • VPN
  • +1
15
58 Views
Last Modified: 2016-10-16
Help, does anyone know how to get the vpn or Internet access in excel macro code and show it as a msgbox? - Jay
0
Comment
Question by:Jay Polo
  • 7
  • 5
  • 2
15 Comments
 
LVL 69

Expert Comment

by:Qlemo
ID: 41803947
I'm not clear what you want to achieve here. Could you elaborate more on what the purpose is exactly?
0
 

Author Comment

by:Jay Polo
ID: 41804528
 Sub ShowMeDetails ()

MsgBox Environ("COMPUTERNAME")
MsgBox Environ("USERPROFILE")
MsgBox Environ("USERDOMAIN")

End Sub 

Open in new window


I need to show as a MsgBox where the user has logged to (see picture, sample MsgBox ("VPN"=group.net).vpn connection
0
 
LVL 69

Expert Comment

by:Qlemo
ID: 41804648
And what if connected with LAN, WiFi and VPN? What to choose to display? And what is the purpose - or, how does it matter at all?
0
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 

Author Comment

by:Jay Polo
ID: 41804673
And what if connected with LAN, WiFi and VPN? yes, if needed. All I need is to get where the user is connected (eg: group.net and would should as a MsgBox)

What to choose to display? just a MsgBox

And what is the purpose - or, how does it matter at all? we are checking how many users are using the VPN, connected at school, at home, or in the office.
0
 

Author Comment

by:Jay Polo
ID: 41804677
Sub ShowMeDetails ()

MsgBox Environ("COMPUTERNAME")
MsgBox Environ("USERPROFILE")
MsgBox Environ("USERDOMAIN")
MsgBox ("VPN = Internet Access") 'I need this code to run my file

End Sub

Open in new window

0
 
LVL 69

Assisted Solution

by:Qlemo
Qlemo earned 250 total points (awarded by participants)
ID: 41804728
Usually you generate a single (text) report file for that purpose, containing above environment variables and the result of ipconfig /all in a batch file:
@echo off
(
  set computername
  set userprofile
  set userdomain
  ipconfig /all
) > %temp%\diag.txt

Open in new window

Create that batch file, run it with the .Shell method, and then e.g. read in the text file created to display, or open it with notepad.
0
 

Author Comment

by:Jay Polo
ID: 41804732
is this MS Excel VBA Macro?
0
 
LVL 69

Expert Comment

by:Qlemo
ID: 41805067
No, it is a cmd.exe batch file (.cmd or .bat).
0
 

Author Comment

by:Jay Polo
ID: 41805248
Aww. I appreciate your efforts. But I would need something Excel macro related language. :(
0
 
LVL 69

Expert Comment

by:Qlemo
ID: 41805266
You know your way to output stuff results in "endless" message boxes popping up each with a single information? Not user-friendly ...
We certainly can provide code to generate the batch file, run it, and display the results from VBA, but I'm not sure you should want to do that ...
0
 

Author Comment

by:Jay Polo
ID: 41805296
I'll try that one if it's ok? hopefully that would complete this file.
0
 

Author Comment

by:Jay Polo
ID: 41809105
up :(
0
 
LVL 39

Accepted Solution

by:
als315 earned 250 total points (awarded by participants)
ID: 41818624
You can use this function to get status of named connection (no difference - vpn or other):
Public Function vpn_lookup(vpn_name As String) As String
'vpn_name - name of connection
Dim Sh As Object
Dim ex As Object
Dim cmd As String
Dim l As Integer
cmd = "ipconfig /all"
vpn_lookup = "not connected"
Set Sh = CreateObject("WScript.Shell")
Set ex = Sh.Exec(cmd)
ex.StdIn.Close
cmd = ex.StdOut.ReadAll
If InStr(1, cmd, vpn_name) > 0 Then vpn_lookup = "connected"
End Function

Open in new window

Chk_vpn.xlsm
0
 
LVL 39

Expert Comment

by:als315
ID: 41845495
Idea in ipconfig, parsing in vba
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Resolve DNS query failed errors for Exchange
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

777 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