我用VB 6.0开发一个示例ACTIVEX DLL 动态库,有一个过程
- VB code
Sub ListFileInfo() Dim xlapp As Object Dim fso As New FileSystemObject Dim fil As File Dim fld As Folder Dim i As Integer Dim sh As New Worksheet Set xlapp = GetObject(, "Excel.Application") i = 1 Set fld = fso.GetFolder("c:\") Set sh = xlapp.Worksheets("sheet1") With sh .Cells(i, 1) = "文件名" .Cells(i, 2) = "文件大小" .Cells(i, 3) = "最后修改时间" i = i + 1 For Each fil In fld.Files .Cells(i, 1) = fil.Name .Cells(i, 2) = fil.Size .Cells(i, 3) = fil.DateLastModified i = i + 1 Next .Range("a1").CurrentRegion.Columns.AutoFit End WithEnd Sub
WFileListInfo.dll
然后我在Excel VBA工程中引用这个DLL,
代码如下:
- VB code
Sub testCustomActiveX() Dim myDll As clsFile myDll.ListFileInfoEnd Sub
一开始进行几次还行,不过后来总出现如题的问题,不知道是怎么回事哦
------解决方案--------------------------------------------------------
注意要有 New
- VBScript code
Sub testCustomActiveX() Dim myDll As New ClsFile myDll.ListFileInfoEnd Sub