Office中国论坛/Access中国论坛

标题: [求助]如何创建execl文件? [打印本页]

作者: pccat    时间: 2004-12-16 23:11
标题: [求助]如何创建execl文件?
如何才能硬盘里创建一个execl文件?[em06]
作者: fanglin572    时间: 2004-12-17 21:03
[em01]
作者: pccat    时间: 2004-12-20 23:35
这个问题没有能回答吗?要用access的vba创建一个execl文件呀~~~那位大哥能告诉我呀?
作者: 中国制造    时间: 2004-12-21 00:18
  Dim xlSheet As Object

    Set xlSheet = CreateObject("Excel.Sheet.8")

   

    Dim X As Long, Y As Long

    Y = 1

    X = 1

    xlSheet.worksheets(1).Cells(1, 1).Value = "成交条款"

    xlSheet.worksheets(1).Cells(1, 2).Value = "数量"

    xlSheet.worksheets(1).Cells(1, 3).Value = "货代"

    xlSheet.worksheets(1).Cells(1, 4).Value = "数量"

    xlSheet.worksheets(1).Cells(1, 5).Value = "报关行"

    xlSheet.worksheets(1).Cells(1, 6).Value = "数量"

    xlSheet.worksheets(1).Cells(1, 7).Value = "供应商"

    xlSheet.worksheets(1).Cells(1, 8).Value = "数量"

    xlSheet.worksheets(1).Cells(1, 9).Value = "记费重量TOTAL"

    For Y = 1 To Me.listView1.ListItems.Count

       xlSheet.worksheets(1).Cells(Y + 1, 1).Value = Me.listView1.ListItems(Y).Text

       xlSheet.worksheets(1).Cells(Y + 1, 2).Value = Me.listView1.ListItems(Y).SubItems(1)

       xlSheet.worksheets(1).Cells(Y + 1, 3).Value = Me.listView1.ListItems(Y).SubItems(2)

       xlSheet.worksheets(1).Cells(Y + 1, 4).Value = Me.listView1.ListItems(Y).SubItems(3)

       xlSheet.worksheets(1).Cells(Y + 1, 5).Value = Me.listView1.ListItems(Y).SubItems(4)

       xlSheet.worksheets(1).Cells(Y + 1, 6).Value = Me.listView1.ListItems(Y).SubItems(5)

       xlSheet.worksheets(1).Cells(Y + 1, 7).Value = Me.listView1.ListItems(Y).SubItems(6)

       xlSheet.worksheets(1).Cells(Y + 1, 8).Value = Me.listView1.ListItems(Y).SubItems(7)

       xlSheet.worksheets(1).Cells(Y + 1, 9).Value = Me.listView1.ListItems(Y).SubItems(8)

    Next Y

  

    xlSheet.saveas [CurrentProject].[Path] & "\" & Format(Date, "mm.dd") & "发票汇总信息.xls"

    xlSheet.Application.Quit



MsgBox "导出成功!!!!"[em07][em07][em07][em07][em07][em07]

[此贴子已经被作者于2004-12-20 16:20:39编辑过]






欢迎光临 Office中国论坛/Access中国论坛 (http://www.office-cn.net/) Powered by Discuz! X3.3