标签:Dim End Sub 打印 rowCount PrintForm col
1 Sub Print_Click() 2 '打印信息 3 Dim columnCount As Integer '列数 4 Dim rowCount As Integer '行数 5 columnCount = getColumnCount(XsXxSheet) 6 rowCount = Application.CountA(ActiveSheet.Range("B:B")) 7 If rowCount = 0 Then 8 MsgBox ("没有数据,无需打印!") 9 Exit Sub 10 End If 11 If rowCount = 1 Then 12 MsgBox ("没有数据,无需打印!") 13 Exit Sub 14 End If 15 '提示信息 16 Dim mess As String 17 Worksheets("错误信息").Visible = True 18 mess = Sheets("错误信息").Cells(1, 1) 19 notContinueBool = True 20 If mess = "" Then 21 ShowForm.MessageLabel.Caption = "学生信息还未进行校验,是否进行打印?" 22 ShowForm.Show 23 ElseIf InStr(mess, "数据校验成功") > 0 Then 24 notContinueBool = False 25 Else 26 ShowForm.MessageLabel.Caption = "学生基本信息中存在错误,是否继续打印?" 27 ShowForm.Show 28 End If 29 ShowForm.Hide 30 If notContinueBool Then 31 ShowForm.Hide 32 Exit Sub 33 End If 34 35 PrintForm.Show 36 Dim beginInt As Integer 37 Dim endInt As Integer 38 If PrintForm.AllOptionButton = Flase And PrintForm.NumOptionButton = Flase Then 39 Exit Sub 40 End If 41 If PrintForm.AllOptionButton Then 42 beginInt = 2 43 endInt = rowCount 44 ElseIf PrintForm.NumOptionButton Then 45 beginInt = PrintForm.FromTextBox 46 endInt = PrintForm.ToTextBox 47 End If 48 If beginInt > rowCount Then 49 MsgBox ("没有需要打印的数据!") 50 Exit Sub 51 End If 52 If endInt > rowCount Then 53 endInt = rowCount 54 End If 55 Worksheets("学生信息打印模板").Visible = True 56 '弹出打印提示窗口 57 '循环1--行 58 For ro = beginInt To endInt 59 '循环2--列 填写学生模板信息-->生成新的Excel 60 For col = 1 To columnCount 61 Title = Sheets(XsXxSheet).Cells(1, col) 62 If Title <> "" Then 63 Dim content As String 64 content = Sheets(XsXxSheet).Cells(ro, col) 65 Dim exl As TypeValueCell 66 exl.cellName = Title 67 exl.cellContent = content 68 aa = fileXsExportModel(exl) 69 End If 70 Next col 71 Worksheets("学生信息打印模板").PrintOut 72 Next ro 73 '清空模板 74 For col = 1 To columnCount 75 Title = Sheets(XsXxSheet).Cells(1, col) 76 If Title <> "" Then 77 Dim content2 As String 78 content2 = Sheets(XsXxSheet).Cells(2, col) 79 Dim exl2 As TypeValueCell 80 exl2.cellName = Title 81 exl2.cellContent = content1 82 bb = clearXsExportModel(exl2) 83 End If 84 Next col 85 Worksheets("学生信息打印模板").Visible = False 86 End Sub
标签:Dim,End,Sub,打印,rowCount,PrintForm,col 来源: https://www.cnblogs.com/xiehaofeng/p/11616956.html
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。