|
模块内容:
Option Compare Database
Option Explicit
Public Function FileExistCheck(ByVal strfilename As String) As Integer
''测试路径是否有效
'这段代码更好
'返回0代表文件或路径不存在
'返回1代表该文件存在
'返回2代表该文件夹存在
Dim intAttr As Integer
On Error GoTo Err:
FileExistCheck = 0
If Len(strfilename) > 0 Then
intAttr = GetAttr(strfilename)
If (intAttr And vbDirectory) Then
FileExistCheck = 2 '
Else
FileExistCheck = 1 '
End If
End If
Exit Function
Err:
End Function
引用地方1:
Private Sub Command246_Click()
Dim lngRe As Long
Dim tempth As String
Dim fulltempth As String
tempth = "\\192.168.56.10\Application\lighting\Report\"
fulltempth = tempth & Me.zuhe1.Value & "报告书.pdf"
If FileExistCheck(fulltempth) = 0 Then
MsgBox "文件不存在!"
Exit Sub
End If
lngRe = ShellExecute(Me.hwnd, "open", tempth & Me.zuhe1.Value & "报告书.pdf", vbNullString, vbNullString, SW_SHOWNORMAL)
If lngRe = SE_ERR_NOASSOC Then
Shell "rundll32 shell32,OpenAs_RunDLL " & tempth & Me.zuhe1.Value & "报告书.pdf", vbNormalFocus
End If
End Sub
引用地方2:
Dim TempPath As String
Dim TempFullPath As String
Dim i As Integer
TempPath = "\\192.168.56.10\Application\lighting\Photo"
p1 = TempPath & "\" & Me.zuhe1.Column(0) & "-1.bmp"
p2 = TempPath & "\" & Me.zuhe1.Column(0) & "-2.bmp"
p3 = TempPath & "\" & Me.zuhe1.Column(0) & "-3.bmp"
p4 = TempPath & "\" & Me.zuhe1.Column(0) & "-4.bmp"
For i = 0 To 4
TempFullPath = TempPath & "\" & Me.zuhe1.Column(0) & "-" & i & ".bmp"
If FileExistCheck(TempFullPath) = 1 Then Me.Controls("ActiveXCtl" & 223 + i).Picture = LoadPicture(TempFullPath) Else Me.Controls("ActiveXCtl" & 223 + i).Picture = LoadPicture(TempPath & "\null.jpg")
Next
Err:
' Debug.Print Err.Description, Err.Number
Exit Sub |
|