|
运行如下代码时候错误,提示加载DLL错误,
Private Sub Command2_Click()
'声明excel对象添加文件
Dim objExcel As Excel.Application
Set objExcel = CreateObject("Excel.Application")
Dim strFile As Variant '选中文件集数组
Dim strFilename As String '单个选中文件名
Dim strFile_loc As String '文件目录名
Dim row_num As Long '保留
Dim file_num, i As Long '文件数
Dim POS As Long '分隔符位置
Dim path_pos As Long '路径位置
strFile = Excel.Application.GetOpenFilename(, , "选择数据文件", "", True)
On Error GoTo ErrHandler
If UBound(strFile) > 0 Then
On Error GoTo ErrHandler
file_num = UBound(strFile)
On Error GoTo ErrHandler
row_num = 3
strFile_loc = ""
POS = 1
For i = 1 To file_num
strFilename = strFile(i)
If i = 1 Then
Do While POS > 0
path_pos = POS
POS = InStr(POS + 1, strFilename, "\", vbTextCompare)
Loop
File_Loc = Left(strFilename, path_pos - 1)
Label11.Caption = File_Loc
End If
'file_List.AddItem (Right(strFilename, Len(strFilename) - path_pos))
file_List.AddItem (strFilename)
Next
End If
Command17.Enabled = True
ErrHandler:
Exit Sub
End Sub |
|