判断局域网中是否存在共享的文件或者文件夹使用dir是无效的,还有局域网中不需要application,你可以参照以下的代码测试一下,具体的局域网路径请根据自己的实际情况更换。
if bExistsFolder("\\192.168.1.101\photo\" & Me.活动主题 & ".jpg",2) =True Then
Me.Image14.Picture = "\\192.168.1.101\photo\" & Me.活动主题 & ".jpg"
end if
'以下的函数先新建个模块,放在模块中。
'函数名称: bExistsFolder
'功能描述: 判断文件夹或者文件是否存在
'输入参数: strPath 必需的,共享或者存放附件的文件夹或文件路径。
' iType 必需的,1代表文件夹,2代表文件
'返回参数: True或False
'使用示例: bExistsFolder("\\192.168.1.10\共享文件夹\",1) '判断文件夹
' bExistsFolder("\\192.168.1.10\共享文件夹\测试.txt",2) '判断文件
'作 者: 金宇
'创建日期: 2012-05-30
Public Function bExistsFolder(strPath As String, iType As Integer) As Boolean
Dim FSO As Object
Set FSO = CreateObject("Scripting.FileSystemObject")
Select Case iType
Case 1 '文件夹
If FSO.FolderExists(strPath) Then
bExistsFolder = True
End If
Case 2 '文件
If FSO.FileExists(strPath) = True Then
bExistsFolder = True
End If
Case Else
MsgBox "参数传递错误!", vbCritical, "错误"
Exit Function
End Select
Set FSO = Nothing
End Function