Excel有自己的档案格式~不能用写文字档的方式写出来~
下面例子你在自己去拆Text1和Text2里面的资料看要怎切割~
Private Sub Command2_Click()
Dim xlApp As New Excel.Application '定义EXCEL类
Dim xlBook As Excel.Workbook '定义工件簿类
Dim xlsheet As Excel.Worksheet '定义工作表类
Dim i, j
Set xlApp = CreateObject("Excel.Application") ''创建EXCEL应用类
xlApp.Visible = True ''设置EXCEL可见
' xlApp.Visible = False ''设置EXCEL可见
Set xlBook = xlApp.Workbooks.Add
Set xlBook = xlApp.Workbooks.Item("Book1") ''先新增需要的工作页
Set xlsheet = xlBook.Sheets(1)
xlsheet.Activate
For i = 1 To 10
For j = 1 To 2
If j = 1 Then
xlsheet.Cells(i, j) = Text1.Text
Else
xlsheet.Cells(i, j) = Text2.Text
End If
Next j
Next i
xlApp.ActiveWorkbook.SaveAs ("D:\AAA.xls")
End Sub
Private Sub Form_Load()
Dim FileNum As Integer, TempString As String
FileNum = FreeFile
Open "D:\ptarp.conf" For Input As #FileNum
Do While Not EOF(FileNum)
Line Input #FileNum, TempString
Text1.Text = Text1.Text & TempString & vbCrLf
Text2.Text = Text2.Text & TempString & vbCrLf
Loop
Close #FileNum
End Sub
P.S 我是新手