在Access中开发应用程序。访问文件将位于数据库中,但是当用户需要使用它时,我希望他们将其复制到桌面上。如果他们将它从G:\驱动器(我们的网络文件夹)上运行,它应该给它们一条消息。确定路径是否为网络路径VBA
那么有没有Win API会帮我解决这个问题? 我打算将此代码放置在窗体的Form_Load事件中。
在Access中开发应用程序。访问文件将位于数据库中,但是当用户需要使用它时,我希望他们将其复制到桌面上。如果他们将它从G:\驱动器(我们的网络文件夹)上运行,它应该给它们一条消息。确定路径是否为网络路径VBA
那么有没有Win API会帮我解决这个问题? 我打算将此代码放置在窗体的Form_Load事件中。
如果要防止用户打开你的来自G:\驱动器的数据库,您可以使用以下代码在启动表单中进行简单检查:
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
您可以使用FileSystemObject DriveType属性
http://msdn.microsoft.com/en-us/library/ea5ht6ax(VS.85).aspx
如果您需要的桌面文件夹,你可能会想看看:
CreateObject("WScript.Shell").SpecialFolders("Desktop")
我不能想出你说你想做什么的任何理由。你能解释一下为什么*? – 2010-07-16 00:41:32