第一段
Private Sub Command2_Click()
Dim xl
Set xl = CreateObject("Excel.Application")
xl.Visible = True
xl.Application.Quit
Set xl = Nothing
End Sub
第二段
Private Sub Command3_Click()
Dim xl
Set xl = CreateObject("Excel.Application")
xl.Visible = True
xl.Quit
Set xl = Nothing
End Sub
第三段
Private Sub Command4_Click()
On Error Resume Next
Dim fileaddress()
Dim path As String
path = "C:\configdata.xls"
Dim i As Integer, k As Integer
Dim gxl1 As Object, gbook1 As Object, gwkssheet1 As Object, cell1 As Object, cell2 As Object
Set gxl1 = CreateObject("Excel.Application")
On Error GoTo 0
gxl1.Visible = True
gxl1.DisplayAlerts = False
'打开配置文件,读取数据
Set gbook1 = gxl1.Workbooks.Open(path)
Set gwkssheet1 = gbook1.Sheets("Sheet1")
Set cell1 = gwkssheet1.Range("A2")
Set cell2 = gwkssheet1.Range("A65536").End(xlUp)
k = cell2.Row - 1
ReDim fileaddress(1 To k)
For i = 1 To k
fileaddress(i) = Cells(cell1.Row + i - 1, 1).Value
Next
gbook1.Close
gxl1.Application.Quit
config = fileaddress
Set cell1 = Nothing
Set cell2 = Nothing
Set gwkssheet1 = Nothing
Set gbook1 = Nothing
Set gxl1 = Nothing
Erase fileaddress
End Sub