快表软件

标题: 资产按明细生成标签 [打印本页]

作者: tony-zyh    时间: 2018-2-27 08:38
标题: 资产按明细生成标签
本人不会VBA,网上也有贴子关于生成标签的,内容格式类似,请求远程协助,附模板。

作者: hessen    时间: 2018-2-27 08:38
本帖最后由 hessen 于 2018-3-7 14:05 编辑

(, 下载次数: 210)

  1. Public Sub ButtunClick(sender As Object, e As SpreadsheetGear.Windows.Co**ols.ShapeActionEventArgs) Implements Interfaces.IExcelWorkBook.ButtunClick
  2. ActiveWorkbook.WorkbookSet.GetLock()
  3. Dim dr As Integer
  4. If e.Shape.Name = "Button Select" Then
  5. ActiveWorkbook.Worksheets("标签打印").Select()
  6. End If
  7. If e.Shape.Name = "Button Copy" Then
  8. dr = (Int(ActiveWorkbook.Worksheets("固定资产档案").Range("T_358").RowCount / 3) + 1) * 6 + 6
  9. ActiveWorkbook.Worksheets("标签打印").Range("A7:F" & dr & "").EntireRow.Delete()
  10. ActiveWorkbook.Worksheets("标签打印").Range("A1:F6").AutoFill(destination:=ActiveWorkbook.Worksheets("标签打印").Range("A1:F" & dr & ""), autoFillType:=AutoFillType.FillDefault)
  11. Dim x, y, m As Integer
  12. Dim a1, a2 As String
  13. m = 9
  14. For x = 6 To dr - 6 Step 6
  15. For y = 0 To 5 Step 2
  16. a1 = AW.ActiveWorksheet.Cells(x, y).Address
  17. a2 = AW.ActiveWorksheet.Cells(x, y + 1).Address
  18. ActiveWorkbook.Worksheets("标签打印").Range(a1 + ":" + a2).Merge()
  19. ActiveWorkbook.Worksheets("标签打印").Cells(x + 1, y + 1).Value = ActiveWorkbook.Worksheets("固定资产档案").Cells(m, 0).Value
  20. ActiveWorkbook.Worksheets("标签打印").Cells(x + 2, y + 1).Value = ActiveWorkbook.Worksheets("固定资产档案").Cells(m, 1).Text
  21. ActiveWorkbook.Worksheets("标签打印").Cells(x + 3, y + 1).Value = ActiveWorkbook.Worksheets("固定资产档案").Cells(m, 2).Value
  22. ActiveWorkbook.Worksheets("标签打印").Cells(x + 4, y + 1).Value = ActiveWorkbook.Worksheets("固定资产档案").Cells(m, 5).Value
  23. ActiveWorkbook.Worksheets("标签打印").Cells(x + 5, y + 1).Value = ActiveWorkbook.Worksheets("固定资产档案").Cells(m, 10).Value
  24. 'ActiveWorkbook.Worksheets("标签打印").Cells(x + 6, y + 1).Value = ActiveWorkbook.Worksheets("固定资产档案").Range("F_3970").Cells(0, 0).Text
  25. 'ActiveWorkbook.Worksheets("标签打印").Cells(x + 7, y + 1).Value = ActiveWorkbook.Worksheets("固定资产档案").Range("F_3970").Cells(0, 0).Text
  26. m = m + 1
  27. Next y
  28. ActiveWorkbook.Worksheets("标签打印").Cells(x + 6, 0).RowHeight = 27
  29. Next x
  30. End If
  31. ActiveWorkbook.WorkbookSet.ReleaseLock()
  32. End Sub '按钮/标签点击事件
复制代码


作者: hessen    时间: 2018-2-27 18:19
本帖最后由 hessen 于 2018-2-27 19:24 编辑

请先参考http://bbs.kuaibiao.cn/forum.php?mod=viewthread&tid=4285

作者: tony-zyh    时间: 2018-3-1 13:51
希望能够远程帮我解决,VBA还不会啊。
作者: tony-zyh    时间: 2018-3-8 13:59
hessen 发表于 2018-3-2 21:53

谢谢!,不好意思现在才看到,您看可否远程协助一下,不胜感激!
作者: hessen    时间: 2018-3-8 17:37
本帖最后由 hessen 于 2018-3-9 09:26 编辑

你用VBA代码生成后填入动态库设置即可,若需远程请留下QQ
作者: tony-zyh    时间: 2018-3-9 08:02
本帖最后由 tony-zyh 于 2018-3-9 08:06 编辑
hessen 发表于 2018-3-8 17:37
你用VBA代码生成后填入动态库设置即可,若需远程请留下QQ,并增加远程支持币费用

QQ:84783477  生成DLL文件会报错。
作者: hessen    时间: 2018-3-9 08:50
  1. AW.WorkbookSet.GetLock()
  2. Dim dr As Integer
  3. If e.Shape.Name = "Button Select" Then
  4. AW.Worksheets("标签打印").Select()
  5. End If
  6. If e.Shape.Name = "Button Copy" Then
  7. dr = (Int(AW.Worksheets("固定资产档案").Range("T_358").RowCount / 3) + 1) * 6 + 6
  8. AW.Worksheets("标签打印").Range("A7:F" & dr & "").EntireRow.Delete()
  9. AW.Worksheets("标签打印").Range("A1:F6").AutoFill(destination:=AW.Worksheets("标签打印").Range("A1:F" & dr & ""), autoFillType:=AutoFillType.FillDefault)
  10. Dim x, y, m As Integer
  11. Dim a1, a2 As String
  12. m = 9
  13. For x = 6 To dr - 6 Step 6
  14. For y = 0 To 5 Step 2
  15. a1 = AW.ActiveWorksheet.Cells(x, y).Address
  16. a2 = AW.ActiveWorksheet.Cells(x, y + 1).Address
  17. AW.Worksheets("标签打印").Range(a1 + ":" + a2).Merge()
  18. AW.Worksheets("标签打印").Cells(x + 1, y + 1).Value = AW.Worksheets("固定资产档案").Cells(m, 0).Value
  19. AW.Worksheets("标签打印").Cells(x + 2, y + 1).Value = AW.Worksheets("固定资产档案").Cells(m, 1).Text
  20. AW.Worksheets("标签打印").Cells(x + 3, y + 1).Value = AW.Worksheets("固定资产档案").Cells(m, 2).Value
  21. AW.Worksheets("标签打印").Cells(x + 4, y + 1).Value = AW.Worksheets("固定资产档案").Cells(m, 5).Value
  22. AW.Worksheets("标签打印").Cells(x + 5, y + 1).Value = AW.Worksheets("固定资产档案").Cells(m, 10).Value
  23. m = m + 1
  24. Next y
  25. AW.Worksheets("标签打印").Cells(x + 6, 0).RowHeight = 27
  26. Next x
  27. End If
  28. AW.WorkbookSet.ReleaseLock()

复制代码
(, 下载次数: 3)

作者: tony-zyh    时间: 2018-3-9 09:33
hessen 发表于 2018-3-9 08:50

谢谢你的热心帮助!
作者: hessen    时间: 2018-3-9 14:16
  1. Option Strict Off
  2. Imports SpreadsheetGear
  3. Imports System.Windows.forms
  4. Namespace ExcelViewVBDotnet
  5. Public Class StandardInterface '自定义名称
  6. '预留位置1
  7. '预留位置2
  8. Dim AW As SpreadsheetGear.IWorkbook,Range As SpreadsheetGear.IRange
  9. Dim dr As Integer
  10. Public Sub Workbook_Open(OldRoot As Object,NewRoot As Object,Excel As SpreadsheetGear.Windows.Forms.WorkbookView)
  11. Excel.GetLock()
  12. AW = Excel.ActiveWorkbook
  13. Range = AW.ActiveWorksheet.Range
  14. Excel.ReleaseLock()

  15. End Sub'打开时执行事件

  16. Public Sub RangeSelection(sender As Object,e As SpreadsheetGear.Windows.Forms.RangeSelectionChangedEventArgs)
  17. 'MessageBox.show("测试")

  18. End Sub'单元格选择后执行的事件

  19. Public Sub RangeChanged(sender As Object,e As SpreadsheetGear.Windows.Forms.RangeChangedEventArgs)

  20. End Sub'单元格编辑完成后执行事件

  21. Public Sub ButtunClick(sender As Object,e As SpreadsheetGear.Windows.Forms.ShapeActionEventArgs)
  22. AW.WorkbookSet.GetLock()
  23. If e.Shape.Name = "Button Select" Then
  24. AW.Worksheets("标签打印").Select()
  25. End If

  26. If e.Shape.Name = "Button Copy" Then
  27. AW.Worksheets("标签打印").Range("A7:F" & dr + 18 & "").EntireRow.Delete()
  28. dr = (Int(AW.Worksheets("固定资产档案").Range("T_358").RowCount / 3) + 1) * 6 + 6
  29. AW.Worksheets("标签打印").Range("A1:F6").AutoFill(destination:=AW.Worksheets("标签打印").Range("A1:F" & dr & ""), autoFillType:=AutoFillType.FillDefault)

  30. Dim x, y, m As Integer
  31. Dim a1, a2 As String
  32. m = 9
  33. For x = 6 To dr - 6 Step 6
  34. For y = 0 To 5 Step 2
  35. a1 = AW.ActiveWorksheet.Cells(x, y).Address
  36. a2 = AW.ActiveWorksheet.Cells(x, y + 1).Address
  37. AW.Worksheets("标签打印").Range(a1 + ":" + a2).Merge()
  38. AW.Worksheets("标签打印").Cells(x + 1, y + 1).Value = AW.Worksheets("固定资产档案").Cells(m, 0).Value
  39. AW.Worksheets("标签打印").Cells(x + 2, y + 1).Value = AW.Worksheets("固定资产档案").Cells(m, 1).Text
  40. AW.Worksheets("标签打印").Cells(x + 3, y + 1).Value = AW.Worksheets("固定资产档案").Cells(m, 2).Value
  41. AW.Worksheets("标签打印").Cells(x + 4, y + 1).Value = AW.Worksheets("固定资产档案").Cells(m, 5).Value
  42. AW.Worksheets("标签打印").Cells(x + 5, y + 1).Value = AW.Worksheets("固定资产档案").Cells(m, 10).Value
  43. m = m + 1
  44. Next y
  45. AW.Worksheets("标签打印").Cells(x + 6, 0).RowHeight = 27
  46. Next x
  47. AW.Worksheets("标签打印").Cells(6, 0).RowHeight = 27
  48. End If
  49. AW.WorkbookSet.ReleaseLock()


  50. End Sub'按钮/标签点击事件

  51. Public Sub FollowHyperlink(sender As Object)

  52. End Sub '暂不支持

  53. End Class
  54. '注:除事件字眼下可以自定义代码外的所有代码不允许改动,否则编译将有可能失败。

  55. End Namespace
复制代码

修复重复生成时提示的问题




欢迎光临 快表软件 (http://bbs.kuaibiao.cn/) Powered by Discuz! X3.4