注册 登录
编程论坛 VB6论坛

为什么CASE 1 不能正确打印啊

wfjt 发布于 2013-05-11 17:42, 527 次点击
Dim xlApp     As New Excel.Application
 Dim xlBook     As Excel.Workbook
 Dim xlSheet As Excel.Worksheet
  xlApp.Visible = False
    Set xlBook = xlApp.Workbooks.Open("mb.xls")
     On Error Resume Next
Select Case rs1.Fields("gsyh")
Case 0
Set xlSheet = xlBook.Worksheets("sheet1")
     With xlSheet
 .Cells(5, 20) = rs.Fields("cust")
.Cells(9, 12) = rs.Fields("numb")
.Cells(6, 3) = DX(rs.Fields("numb"))
.Cells(4, 3) = rs1.Fields("gsmc")
.Cells(5, 3) = rs1.Fields("gszh")
      End With
      xlSheet.PrintOut

Case 1
Set xlSheet = xlBook.Worksheets("sheet3")
     With xlSheet
 .Cells(5, 20) = rs.Fields("cust")
.Cells(9, 12) = rs.Fields("numb")
.Cells(6, 3) = DX(rs.Fields("numb"))
.Cells(4, 3) = rs1.Fields("gsmc")
.Cells(5, 3) = rs1.Fields("gszh")
      End With
        xlSheet.PrintOut
Case 2
Set xlSheet = xlBook.Worksheets("sheet2")
     With xlSheet
 .Cells(2, 4) = rs.Fields("cust")
.Cells(5, 6) = rs.Fields("numb")
.Cells(4, 6) = DX(rs.Fields("numb"))
.Cells(3, 8) = rs1.Fields("gsmc")
.Cells(3, 4) = rs1.Fields("gszh")
      End With
        xlSheet.PrintOut
 Case Else
 MsgBox ("SORRY没有打印模板")
  End Select
 Application.DisplayAlerts = False
 xlBook.Close (False)
  xlApp.quit
 Set xlBook = Nothing
 Set xlApp = Nothing
其他两个都可以打印 求教啊
0 回复
1