Solved

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

Posted on 2016-09-18
15
70 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
[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
  • 7
  • 5
  • 2
15 Comments
 
LVL 70

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 70

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
Simple, centralized multimedia control

Watch and learn to see how ATEN provided an easy and effective way for three jointly-owned pubs to control the 60 televisions located across their three venues utilizing the ATEN Control System, Modular Matrix Switch and HDBaseT extenders.

 

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 70

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 70

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 70

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 40

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 40

Expert Comment

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

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

How to get Spreadsheet Compare 2016 working with the 64 bit version of Office 2016
This article describes a serious pitfall that can happen when deleting shapes using VBA.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

719 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