Determining if a path is a VBA network path

Application development in Access. The access file will be hosted on db, however, when users need to use it, I want them to copy it to the desktop. If they started it from the G: \ drive (our network folder), he should give them a message.

So, is there a Win API that will help me solve this problem? I am going to put this code in the Form_Load event of a form.

+3
source share
4 answers

If you want to prevent users from opening your database from the G: \ drive, you can do a simple check with code similar to this in your startup form:

Dim strMsg As String
If CurrentProject.Path Like "G:*" Then
    strMsg = "Please copy this database file to your " & _
        "local disk and open the copy instead of this one."
    MsgBox strMsg
    Application.Quit
End If

, UNC-, , NotFromHere.txt, , .

Dim strMsg As String
Dim strFilePath
strFilePath = CurrentProject.Path & Chr(92) & "NotFromHere.txt"
If Len(Dir(strFilePath)) > 0 Then
    strMsg = "Please copy this database file to your " & _
        "local disk and open the copy instead of this one."
    MsgBox strMsg
    Application.Quit
End If
+1

FileSystemObject DriveType

http://msdn.microsoft.com/en-us/library/ea5ht6ax(VS.85).aspx

, :

CreateObject("WScript.Shell").SpecialFolders("Desktop")
+1
+1

I think that there is a call in which the (physically) attached disks on the machine will be listed, you can call this and compare the disk specifier along the path that the user gave against the list.

0
source

Source: https://habr.com/ru/post/1754672/


All Articles