我无法弄清楚为什么以下代码会引发编译错误,并显示消息“用户定义的类型未定义”。它突出显示了Set fso = FileSystemObject
Sub S()
Dim fso As FileSystemObject
Dim ts As TextStream
Dim i As Integer
Dim myCell As Range
Set fso = FileSystemObject
For i = 0 To TotalColumnNumber
' last argument, True, says to create the text file if it doesnt exist, which is
' good for us in this case
Set ts = fso.OpenTextFile("column_" & i, ForWriting, True)
' set mycell to the first cell in the ith column
Set myCell = SheetName.Cells(1, i)
' continue looping down the column until you reach a blank cell
' writing each cell value as you go
Do Until myCell.Value = ""
ts.writeline myCell.Value
Set myCell = myCell.Offset(1, 0)
Loop
ts.Close
Next
Set ts = Nothing
Set fso = Nothing
End Sub
谢谢