如题
解决方案 »
- 请教MaskBlt的用法
- 在VB中怎样使MSFlexGrid出现在左栏的工具窗口
- 困惑了我一周多的问题,图片像素的读取,诸位大侠快帮帮我!
- 求各种图像转换为JPG格式的方法或控件!
- 我已经在窗口中用MSHFlexGrid1显示出了一个表中的数据,我现在想通过表中的某个字段来决定MSHFlexGrid1中某行的颜色应该怎么才能实现,想
- MSDN中文网站
- 帮帮我,问题很小 难倒 我了
- CrystalReport报表,怎么让表中的字段从左到右显示,超过3个换页?
- 真诚求教:字符—日期转换函数的相关问题?
- 数据库查询的问题
- 财务账明细中的金额有小数位、个位、十位、百位、千位等等,其中标题栏中的“金额”栏跨多个列
- CommonDialog打开操作并没有进入设置的默认打开位置的问题
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
上面的错误怎么改呢?
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
xlBook1 定义成什么?
LIST更简单啊
遍历一下就行了
免费的学习交流网站,欢迎大家访问!
http://www.j2soft.cn/