Solved

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

Posted on 2016-09-18
15
63 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
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.

 

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

726 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