本帖最后由 安全网 于 2015-10-14 17:35 编辑
Public arr, dc
Sub 读入()
Application.ScreenUpdating = False
Dim x, Y, M, f, L, arr, ARR1(1 To 30000, 1 To 23)
Dim wb As Workbook
Dim t, ps1, ps2
f = ThisWorkbook.Path & "\SN.txt"
Open f For Input As #1
Do While Not EOF(1)
Input #1, ps1, ps2 ' 将数据读入两个变量。
Loop
Close #1
Set wb = Workbooks.Open(Filename:=ThisWorkbook.Path & "\数据表.xls", Password:=Split(ps1, ":")(1), WriteResPassword:=Split(ps2, ":")(1)) '读入
arr = wb.Worksheets(1).[a1].CurrentRegion
Set dc = CreateObject("scripting.dictionary")
wb.Close False
For i = 2 To UBound(arr, 2)
dc(arr(2, i)) = i
Next
Application.ScreenUpdating = True
End Sub
Sub OPENS()
Set wb = Workbooks.Open(Filename:=ThisWorkbook.Path & "\数据表.xls", Password:=Split(ps1, ":")(1), WriteResPassword:=Split(ps2, ":")(1))
End Sub
没什么问题,主要原因就是你在“读入”里面又重新dim了一下arr。
|