ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   VPN Connection (https://www.excelbanter.com/excel-programming/419916-vpn-connection.html)

Jimbob

VPN Connection
 
I have developed an Excel report using ADO database connection - thanks to
the help from you good folks on this forum - but most of my users are remote,
travelling to client sites - wondering if there is a way I can test for a
conneciton to the network/datasource and initiate a VPN connection if
required.

Any suggestions?

Thanks,

Jim

Jim Thomlinson

VPN Connection
 
I test my connection with the following code... Note that m_cDSN, LOGIN_NAME
and LOGIN_PASSWORD are global variables...

Public Function TestConnection() As Boolean
Dim cn As ADODB.Connection

TestConnection = True
Set cn = New ADODB.Connection
On Error GoTo Errorhandler
cn.Open "DSN=" & m_cDSN & ";Uid=" & LOGIN_NAME & ";Pwd=" &
LOGIN_PASSWORD & ";"
cn.Close
Set cn = Nothing
Exit Function
Errorhandler:
TestConnection = False
Set cn = Nothing
End Function

You use it like this...

if TestConnection = false then
msgbox "Connect to VPN and try again"
else
'run the query
end if
--
HTH...

Jim Thomlinson


"JimBob" wrote:

I have developed an Excel report using ADO database connection - thanks to
the help from you good folks on this forum - but most of my users are remote,
travelling to client sites - wondering if there is a way I can test for a
conneciton to the network/datasource and initiate a VPN connection if
required.

Any suggestions?

Thanks,

Jim



All times are GMT +1. The time now is 01:56 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com