Solved

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

Posted on 2016-09-18
  • Windows Networking
  • VBA
  • MS Office
  • MS Excel
  • VPN
  • +1
15
51 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 68

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 68

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
 

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 68

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
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!

 
LVL 68

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 68

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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Using Word 2013, I was experiencing some incredible lag when typing.  Here's what worked for me....
I recently attended Cisco Live! in Las Vegas, a conference that boasted over 28,000 techies in attendance, and a week of hands-on learning hosted by a solid partner with which Concerto goes to market.  Every year, Cisco displays cutting-edge technol…
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

705 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

18 Experts available now in Live!

Get 1:1 Help Now