如题

解决方案 »

  1.   

    execl不能导入么?那list怎么导入到记事本里呢?
      

  2.   

    Private Sub Command2_Click()
        Dim Fname As String
        Dim line As String
        Dim otxt As Scripting.TextStream
        CommonDialog1.Filter = "文本文档|*.txt|电子表格|*.xls|"
        CommonDialog1.ShowSave
        Fname = CommonDialog1.filename
        If Fname <> "" Then
    Open Fname For Output As #1
    Print #1, List2.AddItem(ListIndex)
    Close #1
          End If
    上面的错误怎么改呢?
      

  3.   

    给你一个我写过的程序部分代码
    Private Sub CmdExportD_Click()
        If Me.lvListView.ListItems.Count = 0 Then
            MsgBox "当前时间不存在纪录", , "提示"
            Exit Sub
        End If
        Me.CmdExit.Enabled = False
        Me.CmdExportD.Enabled = False
        Dim i As Long, j As Long, m As Long
            Open "相同的.xls" For Output As #1
        Close #1
        Open "不同的.xls" For Output As #2
        Close #2
        Set xlApp1 = New Excel.Application
        Set xlApp2 = New Excel.Application
        xlApp1.Visible = False
        xlApp2.Visible = False
        Set xlBook1 = xlApp1.Workbooks.Open(App.Path & "\相同的.xls")
        Set xlBook2 = xlApp2.Workbooks.Open(App.Path & "\不同的.xls")
        Set xlsheet1 = xlBook1.Worksheets(1)
        Set xlsheet2 = xlBook2.Worksheets(1)
                
        For i = 1 To Me.lvListView.ListItems.Count
            DoEvents
            If Me.lvListView.ListItems.Item(i).SubItems(5) = "不存在" Then
                j = j + 1
                xlsheet2.Cells(j, 1) = Me.lvListView.ListItems.Item(i).SubItems(1)
                xlsheet2.Cells(j, 2) = Me.lvListView.ListItems.Item(i).SubItems(2)
                xlsheet2.Cells(j, 3) = Me.lvListView.ListItems.Item(i).SubItems(3)
                xlsheet2.Cells(j, 4) = Me.lvListView.ListItems.Item(i).SubItems(4)
                xlsheet2.Cells(j, 5) = Me.lvListView.ListItems.Item(i).SubItems(5)
            Else
                m = m + 1
                xlsheet1.Cells(m, 1) = Me.lvListView.ListItems.Item(i).SubItems(1)
                xlsheet1.Cells(m, 2) = Me.lvListView.ListItems.Item(i).SubItems(2)
                xlsheet1.Cells(m, 3) = Me.lvListView.ListItems.Item(i).SubItems(3)
                xlsheet1.Cells(m, 4) = Me.lvListView.ListItems.Item(i).SubItems(4)
                xlsheet1.Cells(m, 5) = Me.lvListView.ListItems.Item(i).SubItems(5)
            End If
        Next
                
        xlBook1.Save
        xlBook2.Save
        xlBook1.Close False
        xlBook2.Close False
        xlApp1.Quit
        xlApp2.Quit
        Set xlBook1 = Nothing
        Set xlBook2 = Nothing
        Set xlsheet1 = Nothing
        Set xlsheet2 = Nothing
        Set xlApp1 = Nothing
        Set xlApp2 = Nothing
        
        
        MsgBox "导出成功", , "提示"
        Me.CmdExit.Enabled = True
        Me.CmdExportD.Enabled = True
        Exit Sub
    OpenErr:
        Me.CmdExit.Enabled = True
        Me.CmdExportD.Enabled = True
    End Sub
      

  4.   

    If Me.List2.ListItems.Count = 0 Then  `提示未找到方法或数据成员
    xlBook1 定义成什么?
      

  5.   

    LIST没有ListItems啊
    LIST更简单啊
    遍历一下就行了
      

  6.   

    我的网站上有导入EXCEL的源码,你可以下载看看。VB资料->查询“EXCEL”;====================
    免费的学习交流网站,欢迎大家访问!
    http://www.j2soft.cn/