- 帖子
- 109
- 主題
- 2
- 精華
- 0
- 積分
- 114
- 點名
- 0
- 作業系統
- Win7 Win10
- 軟體版本
- Office 2019 WPS
- 閱讀權限
- 20
- 性別
- 男
- 來自
- 深圳
- 註冊時間
- 2013-2-2
- 最後登錄
- 2024-11-6
|
2#
發表於 2016-7-27 16:28
| 只看該作者
- Option Explicit
- #If VBA7 Then
- Private Declare PtrSafe Function PathIsDirectoryW Lib "shlwapi.dll" (ByVal pszPath As LongPtr) As Long
- Private Declare PtrSafe Function PathFileExistsW Lib "shlwapi.dll" (ByVal pszPath As LongPtr) As Long
- #Else
- Private Declare Function PathIsDirectoryW Lib "shlwapi.dll" (ByVal pszPath As Long) As Long
- Private Declare Function PathFileExistsW Lib "shlwapi.dll" (ByVal pszPath As Long) As Long
- #End If
- '检测文件是否存在
- Public Function FileExists(ByVal strPath As String) As Boolean
- strPath = strPath & String(5, vbNullChar)
- If PathFileExistsW(StrPtr(strPath)) Then
- FileExists = PathIsDirectoryW(StrPtr(strPath)) = 0
- End If
- End Function
- Public Sub FilesExists()
- Dim I As Long
- For I = 1 To Range("A" & Rows.Count).End(xlUp).Row
- Range("B" & I).Value = FileExists("\\89.80.70.1\design\add_word\" & Range("A" & I).Value & ".TXT")
- Next I
- End Sub
複製代碼 |
|