Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Checking network connection using vba

Tags:

vba

ms-access

Is there any way to check NEtwork connection in vba?

I am using this command:

If Dir("O:\") = "" Then
    MsgBox "you have network connection"
Else
    MsgBox "No Connection"
End If

but it doesnt work and I am getting a run time error

like image 300
Kaja Avatar asked Dec 26 '22 07:12

Kaja


1 Answers

What you are doing is almost correct except flip the if and else parts,

i.e. when Dir("O:\") = "" = You are not connected

and when it returns something means you have a connection.

The Dir function is used to return the first filename from a specified directory, and list of attributes.

Sub Test_Connection()

 If (Len(Dir("O:\"))) Then
  MsgBox "Connected"
 Else
  MsgBox "No Connection"
 End If

End Sub
like image 56
Ravi Yenugu Avatar answered Jan 26 '23 01:01

Ravi Yenugu