|
各位大神:我写了一段代码如下。我在我电脑上编译运行没有问题,但是我把excel文件和PDF文件放到公司网络盘上调试时,显示这句f = Dir(arr(i), vbDirectory)有问题。具体错误代码如图。请大神帮我看看有啥问题。
Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
Dim arr(1 To 10000) As String
Dim wb As Workbook
Dim f, i, k, f2, f3, x
Dim arr1(1 To 100000, 1 To 13) As String, q As Integer
Dim fso As Object, myfile As Object
If Target.Row > 1 And Target.Column = 2 Then
xt = ActiveCell.Text
arr(1) = ThisWorkbook.Path & "\"
i = 1: k = 1
Do While i < UBound(arr)
If arr(i) = "" Then Exit Do
f = Dir(arr(i), vbDirectory)
Do
If InStr(f, ".") = 0 And f <> "" Then
k = k + 1
arr(k) = arr(i) & f & "\"
End If
f = Dir
Loop Until f = ""
i = i + 1
Loop
Set fso = CreateObject("Scripting.FileSystemObject")
For x = 1 To UBound(arr)
If arr(x) = "" Then Exit For
f3 = Dir(arr(x) & xt & ".pdf")
If f3 <> "" Then
CreateObject("Wscript.Shell").Run (arr(x) & f3)
End If
Next
End If
End Sub
|
-
错误代码
-
公司网盘地址及结构
-
-
示例1.rar
673.8 KB, 下载次数: 0
示例文件
|