Aucune description
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

列印_訂單明細.vb 26KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360
  1. Option Strict Off
  2. Imports Microsoft.Office.Interop.Excel.XlUnderlineStyle
  3. Imports Microsoft.Office.Interop.Excel.Constants
  4. Imports Microsoft.Office.Interop.Excel.XlBordersIndex
  5. Imports Microsoft.Office.Interop.Excel.XlLineStyle
  6. Imports Microsoft.Office.Interop.Excel.XlBorderWeight
  7. Imports Microsoft.Office.Interop.Excel.XlThemeFont
  8. Imports Microsoft.Office.Interop.Excel.XlThemeColor
  9. Imports Microsoft.Office.Interop.Excel.XlWindowState
  10. Public Class 列印_訂單明細
  11. ReadOnly ds As New DataSet
  12. Dim N1 As Integer = 6 : Dim N2 As Integer
  13. Dim M1 As String
  14. Dim xlApp As Microsoft.Office.Interop.Excel.Application
  15. Dim xlBook As Microsoft.Office.Interop.Excel.Workbook
  16. Dim xlSheet As Microsoft.Office.Interop.Excel.Worksheet
  17. Private Sub Set_訂單清單()
  18. DataGridView1.DataSource = Nothing : ds.Clear()
  19. DataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
  20. DataGridView1.ColumnHeadersHeight = 25
  21. DataGridView1.AllowUserToAddRows = False
  22. ConnOpen()
  23. SQL1 = 列印用SQL
  24. CmdSet_For_DGV() : da.SelectCommand.CommandTimeout = 900 : da.Fill(ds) : DataGridView1.DataSource = ds.Tables(0) : conn.Close()
  25. End Sub
  26. Private Sub Set_格式設定()
  27. DataGridView1.Visible = False
  28. End Sub
  29. Private Sub 列印_訂單明細_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  30. FormBorderStyle = FormBorderStyle.SizableToolWindow : ControlBox = False
  31. Set_訂單清單() : Set_格式設定()
  32. End Sub
  33. Private Sub Button11_Click(sender As Object, e As EventArgs) Handles Button11.Click
  34. xlApp = CType(CreateObject("Excel.Application"), Microsoft.Office.Interop.Excel.Application)
  35. xlBook = xlApp.Workbooks.Add
  36. xlApp.DisplayAlerts = True
  37. xlBook.Activate()
  38. xlSheet = NewMethod(xlBook)
  39. xlSheet.Activate()
  40. xlApp.Visible = True
  41. xlApp.Application.WindowState = xlMaximized
  42. xlSheet.Cells(2, 1) = "Number" : xlSheet.Cells(2, 3) = OD(0)
  43. xlSheet.Cells(3, 1) = "Created Date"
  44. xlSheet.Cells(3, 3) = OD(20) 'OD(1)
  45. xlSheet.Cells(4, 1) = "Brand" : xlSheet.Cells(4, 3) = OD(2) : xlSheet.Cells(5, 1) = "Vendor Name" : xlSheet.Cells(5, 3) = OD(3)
  46. xlSheet.Cells(7, 1) = "Mode Of Delivery" : xlSheet.Cells(7, 3) = OD(4) : xlSheet.Cells(8, 1) = "Delivery Terms" : xlSheet.Cells(8, 3) = OD(5)
  47. xlSheet.Cells(9, 1) = "Ship from name Ship from address" : xlSheet.Cells(9, 3) = OD(6)
  48. xlSheet.Cells(2, 4) = "Org. Ship Date" : xlSheet.Cells(2, 6) = OD(21) : xlSheet.Cells(3, 4) = "From Port" : xlSheet.Cells(3, 6) = OD(8)
  49. xlSheet.Cells(4, 4) = "To Port" : xlSheet.Cells(4, 6) = OD(9) : xlSheet.Cells(5, 4) = "Shipping Carrier" : xlSheet.Cells(5, 6) = OD(10)
  50. xlSheet.Cells(6, 4) = "Customer Requisition" : xlSheet.Cells(6, 6) = OD(39) : xlSheet.Cells(7, 4) = "Vendor Reference" : xlSheet.Cells(7, 6) = OD(11)
  51. 'xlSheet.Cells(2, 8) = "Modified Date" : xlSheet.Cells(2, 10) = OD(12)
  52. xlSheet.Cells(3, 8) = "Customer Name" : xlSheet.Cells(3, 10) = OD(13)
  53. xlSheet.Cells(4, 8) = "Ship Date" : xlSheet.Cells(4, 10) = OD(14)
  54. 'xlSheet.Cells(5, 8) = "Sales Order" : xlSheet.Cells(5, 10) = OD(15) : xlSheet.Cells(6, 8) = "ETA Date" : xlSheet.Cells(6, 10) = OD(16)
  55. xlSheet.Cells(8, 8) = "Delivery Address" : xlSheet.Cells(8, 10) = OD(17)
  56. xlSheet.Cells(2, 13) = OD(18) : xlSheet.Cells(3, 13) = "工廠:" : xlSheet.Cells(3, 14) = OD(19)
  57. xlSheet.Cells(4, 13) = "下單日:" : xlSheet.Cells(4, 14) = OD(20) : xlSheet.Cells(5, 13) = "交期:" : xlSheet.Cells(5, 14) = OD(21) : xlSheet.Cells(6, 13) = OD(40)
  58. xlSheet.Cells(16, 1) = "Item Number" : xlSheet.Cells(16, 2) = "Product Name" : xlSheet.Cells(16, 3) = "Product Description"
  59. xlSheet.Cells(16, 4) = "Color" : xlSheet.Cells(16, 5) = "DM"
  60. If OD(22) <> 0 Then : xlSheet.Cells(16, N1) = "5" : N1 += 1 : End If : If OD(23) <> 0 Then : xlSheet.Cells(16, N1) = "5.5" : N1 += 1 : End If
  61. If OD(24) <> 0 Then : xlSheet.Cells(16, N1) = "6" : N1 += 1 : End If : If OD(25) <> 0 Then : xlSheet.Cells(16, N1) = "6.5" : N1 += 1 : End If
  62. If OD(26) <> 0 Then : xlSheet.Cells(16, N1) = "7" : N1 += 1 : End If : If OD(27) <> 0 Then : xlSheet.Cells(16, N1) = "7.5" : N1 += 1 : End If
  63. If OD(28) <> 0 Then : xlSheet.Cells(16, N1) = "8" : N1 += 1 : End If : If OD(29) <> 0 Then : xlSheet.Cells(16, N1) = "8.5" : N1 += 1 : End If
  64. If OD(30) <> 0 Then : xlSheet.Cells(16, N1) = "9" : N1 += 1 : End If : If OD(31) <> 0 Then : xlSheet.Cells(16, N1) = "9.5" : N1 += 1 : End If
  65. If OD(32) <> 0 Then : xlSheet.Cells(16, N1) = "10" : N1 += 1 : End If : If OD(33) <> 0 Then : xlSheet.Cells(16, N1) = "10.5" : N1 += 1 : End If
  66. If OD(34) <> 0 Then : xlSheet.Cells(16, N1) = "11" : N1 += 1 : End If : If OD(41) <> 0 Then : xlSheet.Cells(16, N1) = "11.5" : N1 += 1 : End If
  67. If OD(35) <> 0 Then : xlSheet.Cells(16, N1) = "12" : N1 += 1 : End If : If OD(42) <> 0 Then : xlSheet.Cells(16, N1) = "12.5" : N1 += 1 : End If
  68. If OD(36) <> 0 Then : xlSheet.Cells(16, N1) = "13" : N1 += 1 : End If : If OD(37) <> 0 Then : xlSheet.Cells(16, N1) = "14" : N1 += 1 : End If
  69. xlSheet.Cells(16, N1) = "TOTAL"
  70. For i As Integer = 0 To DataGridView1.Rows.Count - 1
  71. xlSheet.Cells(i + 17, 1) = DataGridView1.Rows(i).Cells("ItemNumber").Value
  72. xlSheet.Cells(i + 17, 2) = DataGridView1.Rows(i).Cells("ProductName").Value
  73. xlSheet.Cells(i + 17, 3) = DataGridView1.Rows(i).Cells("ProductDescription").Value
  74. xlSheet.Cells(i + 17, 4) = DataGridView1.Rows(i).Cells("Color").Value
  75. xlSheet.Cells(i + 17, 5) = DataGridView1.Rows(i).Cells("DM").Value
  76. N1 = 6
  77. If OD(22) <> 0 Then : xlSheet.Cells(i + 17, N1) = DataGridView1.Rows(i).Cells("5").Value : N1 += 1 : End If
  78. If OD(23) <> 0 Then : xlSheet.Cells(i + 17, N1) = DataGridView1.Rows(i).Cells("5.5").Value : N1 += 1 : End If
  79. If OD(24) <> 0 Then : xlSheet.Cells(i + 17, N1) = DataGridView1.Rows(i).Cells("6").Value : N1 += 1 : End If
  80. If OD(25) <> 0 Then : xlSheet.Cells(i + 17, N1) = DataGridView1.Rows(i).Cells("6.5").Value : N1 += 1 : End If
  81. If OD(26) <> 0 Then : xlSheet.Cells(i + 17, N1) = DataGridView1.Rows(i).Cells("7").Value : N1 += 1 : End If
  82. If OD(27) <> 0 Then : xlSheet.Cells(i + 17, N1) = DataGridView1.Rows(i).Cells("7.5").Value : N1 += 1 : End If
  83. If OD(28) <> 0 Then : xlSheet.Cells(i + 17, N1) = DataGridView1.Rows(i).Cells("8").Value : N1 += 1 : End If
  84. If OD(29) <> 0 Then : xlSheet.Cells(i + 17, N1) = DataGridView1.Rows(i).Cells("8.5").Value : N1 += 1 : End If
  85. If OD(30) <> 0 Then : xlSheet.Cells(i + 17, N1) = DataGridView1.Rows(i).Cells("9").Value : N1 += 1 : End If
  86. If OD(31) <> 0 Then : xlSheet.Cells(i + 17, N1) = DataGridView1.Rows(i).Cells("9.5").Value : N1 += 1 : End If
  87. If OD(32) <> 0 Then : xlSheet.Cells(i + 17, N1) = DataGridView1.Rows(i).Cells("10").Value : N1 += 1 : End If
  88. If OD(33) <> 0 Then : xlSheet.Cells(i + 17, N1) = DataGridView1.Rows(i).Cells("10.5").Value : N1 += 1 : End If
  89. If OD(34) <> 0 Then : xlSheet.Cells(i + 17, N1) = DataGridView1.Rows(i).Cells("11").Value : N1 += 1 : End If
  90. If OD(41) <> 0 Then : xlSheet.Cells(i + 17, N1) = DataGridView1.Rows(i).Cells("11.5").Value : N1 += 1 : End If
  91. If OD(35) <> 0 Then : xlSheet.Cells(i + 17, N1) = DataGridView1.Rows(i).Cells("12").Value : N1 += 1 : End If
  92. If OD(42) <> 0 Then : xlSheet.Cells(i + 17, N1) = DataGridView1.Rows(i).Cells("12.5").Value : N1 += 1 : End If
  93. If OD(36) <> 0 Then : xlSheet.Cells(i + 17, N1) = DataGridView1.Rows(i).Cells("13").Value : N1 += 1 : End If
  94. If OD(37) <> 0 Then : xlSheet.Cells(i + 17, N1) = DataGridView1.Rows(i).Cells("14").Value : N1 += 1 : End If
  95. xlSheet.Cells(i + 17, N1) = DataGridView1.Rows(i).Cells("TOTAL").Value
  96. With xlApp.Selection
  97. .Font.Bold = True
  98. End With
  99. N2 = i
  100. Next i
  101. N1 = 5 : N2 += 3
  102. xlSheet.Cells(N2 + 17, N1) = "合計" : N1 += 1
  103. If OD(22) <> 0 Then : xlSheet.Cells(N2 + 17, N1) = OD(22) : N1 += 1 : End If : If OD(23) <> 0 Then : xlSheet.Cells(N2 + 17, N1) = OD(23) : N1 += 1 : End If '5 5.5
  104. If OD(24) <> 0 Then : xlSheet.Cells(N2 + 17, N1) = OD(24) : N1 += 1 : End If : If OD(25) <> 0 Then : xlSheet.Cells(N2 + 17, N1) = OD(25) : N1 += 1 : End If '6 6.5
  105. If OD(26) <> 0 Then : xlSheet.Cells(N2 + 17, N1) = OD(26) : N1 += 1 : End If : If OD(27) <> 0 Then : xlSheet.Cells(N2 + 17, N1) = OD(27) : N1 += 1 : End If '7 7.5
  106. If OD(28) <> 0 Then : xlSheet.Cells(N2 + 17, N1) = OD(28) : N1 += 1 : End If : If OD(29) <> 0 Then : xlSheet.Cells(N2 + 17, N1) = OD(29) : N1 += 1 : End If '8 8.5
  107. If OD(30) <> 0 Then : xlSheet.Cells(N2 + 17, N1) = OD(30) : N1 += 1 : End If : If OD(31) <> 0 Then : xlSheet.Cells(N2 + 17, N1) = OD(31) : N1 += 1 : End If '9 9.5
  108. If OD(32) <> 0 Then : xlSheet.Cells(N2 + 17, N1) = OD(32) : N1 += 1 : End If : If OD(33) <> 0 Then : xlSheet.Cells(N2 + 17, N1) = OD(33) : N1 += 1 : End If '10 10.5
  109. If OD(34) <> 0 Then : xlSheet.Cells(N2 + 17, N1) = OD(34) : N1 += 1 : End If : If OD(41) <> 0 Then : xlSheet.Cells(N2 + 17, N1) = OD(41) : N1 += 1 : End If '11 11.5
  110. If OD(35) <> 0 Then : xlSheet.Cells(N2 + 17, N1) = OD(35) : N1 += 1 : End If : If OD(42) <> 0 Then : xlSheet.Cells(N2 + 17, N1) = OD(42) : N1 += 1 : End If '12 12.5
  111. If OD(36) <> 0 Then : xlSheet.Cells(N2 + 17, N1) = OD(36) : N1 += 1 : End If : If OD(37) <> 0 Then : xlSheet.Cells(N2 + 17, N1) = OD(37) : N1 += 1 : End If '13 14
  112. xlSheet.Cells(N2 + 17, N1) = OD(38)
  113. BB(xlApp, xlSheet)
  114. xlSheet.PageSetup.PrintArea = ""
  115. xlApp.Cells.Select()
  116. xlSheet.Range("B1").Select()
  117. xlApp.Application.WindowState = xlMinimized
  118. MsgBox("列印完成")
  119. Me.Close()
  120. End Sub
  121. Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
  122. 列印用SQL = "" : Me.Close()
  123. End Sub
  124. Private Shared Function NewMethod(xlBook As Microsoft.Office.Interop.Excel.Workbook) As Microsoft.Office.Interop.Excel.Worksheet
  125. Return CType(xlBook.Worksheets.Add, Microsoft.Office.Interop.Excel.Worksheet)
  126. End Function
  127. Private Sub BB(ByVal myExcel As Microsoft.Office.Interop.Excel.Application, ByVal xlSheet As Microsoft.Office.Interop.Excel.Worksheet)
  128. Dim 位置1 As String
  129. If N1 = 7 Then : M1 = "G" : ElseIf N1 = 8 Then : M1 = "H" : ElseIf N1 = 9 Then : M1 = "I" : ElseIf N1 = 10 Then : M1 = "J"
  130. ElseIf N1 = 11 Then : M1 = "K" : ElseIf N1 = 12 Then : M1 = "L" : ElseIf N1 = 13 Then : M1 = "M" : ElseIf N1 = 14 Then : M1 = "N"
  131. ElseIf N1 = 15 Then : M1 = "O" : ElseIf N1 = 16 Then : M1 = "P" : ElseIf N1 = 17 Then : M1 = "Q" : ElseIf N1 = 18 Then : M1 = "R"
  132. ElseIf N1 = 19 Then : M1 = "S" : ElseIf N1 = 20 Then : M1 = "T" : ElseIf N1 = 21 Then : M1 = "U" : ElseIf N1 = 22 Then : M1 = "V"
  133. ElseIf N1 = 23 Then : M1 = "W" : ElseIf N1 = 24 Then : M1 = "X" : End If
  134. xlSheet.Cells.Select()
  135. With myExcel.Selection.Font
  136. .Name = "微軟正黑體" : .Size = 9 : .Strikethrough = False : .Superscript = False : .Subscript = False : .OutlineFont = False : .Shadow = False
  137. .Underline = xlUnderlineStyleNone : .ThemeColor = xlThemeColorLight1 : .TintAndShade = 0 : .ThemeFont = xlThemeFontNone
  138. End With
  139. xlSheet.Columns("A:A").Select : myExcel.Selection.ColumnWidth = 10
  140. xlSheet.Columns("B:B").Select : myExcel.Selection.ColumnWidth = 12
  141. xlSheet.Columns("C:C").Select : myExcel.Selection.ColumnWidth = 24
  142. xlSheet.Columns("D:E").Select : myExcel.Selection.ColumnWidth = 10
  143. xlSheet.Columns("F:V").Select : myExcel.Selection.ColumnWidth = 6
  144. xlSheet.Rows("16:16").Select : myExcel.Selection.RowHeight = 30
  145. 位置1 = "17:" & N2 + 14 : xlSheet.Rows(位置1).Select : myExcel.Selection.RowHeight = 25
  146. 位置1 = "A17:E" & N2 + 14
  147. xlSheet.Range(位置1).Select()
  148. With myExcel.Selection
  149. .HorizontalAlignment = xlLeft : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  150. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False
  151. End With
  152. With myExcel.Selection
  153. .HorizontalAlignment = xlLeft : .VerticalAlignment = xlCenter : .WrapText = True : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  154. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False
  155. End With
  156. 位置1 = "F17:V" & N2 + 17 : xlSheet.Range(位置1).Select() : myExcel.Selection.NumberFormatLocal = "#,##0"
  157. 位置1 = "A16:" & M1 & N2 + 14 : xlSheet.Range(位置1).Select()
  158. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  159. With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  160. With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  161. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  162. With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  163. With myExcel.Selection.Borders(xlInsideVertical) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  164. With myExcel.Selection.Borders(xlInsideHorizontal) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  165. 位置1 = "A16:" & M1 & "16" : xlSheet.Range(位置1).Select()
  166. With myExcel.Selection.Interior
  167. .Pattern = xlSolid : .PatternColorIndex = xlAutomatic : .ThemeColor = xlThemeColorAccent1 : .TintAndShade = 0.599993896298105 : .PatternTintAndShade = 0
  168. End With
  169. 位置1 = "A16:" & M1 & "16" : xlSheet.Range(位置1).Select()
  170. With myExcel.Selection
  171. .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False
  172. .IndentLevel = 0 : .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False
  173. End With
  174. xlSheet.Range("A2:B2,A3:B3,A4:B4,A5:B6,C5:C6,A7:B7,A8:B8,A9:B15,C9:C15").Select() : xlSheet.Range("C9").Activate()
  175. With myExcel.Selection
  176. .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  177. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False
  178. End With
  179. myExcel.Selection.Merge
  180. xlSheet.Range("D2:E2,D3:E3,D4:E4,D5:E5,D6:E6,F2:G2,F3:G3,F4:G4,F5:G5,F6:G6").Select() : xlSheet.Range("F6").Activate()
  181. With myExcel.Selection
  182. .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  183. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False
  184. End With
  185. myExcel.Selection.Merge
  186. xlSheet.Range("H2:I2,H3:I3,H4:I4,H5:I5,H6:I7,H8:I15,J2:L2,J3:L3,J4:L4,J5:L5,J6:L7,J8:L15").Select() : xlSheet.Range("J8").Activate()
  187. With myExcel.Selection
  188. .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  189. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False
  190. End With
  191. myExcel.Selection.Merge
  192. xlSheet.Range("M2:O2,N3:O3,N4:O4,N5:O5").Select() : xlSheet.Range("N5").Activate()
  193. With myExcel.Selection
  194. .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  195. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False
  196. End With
  197. myExcel.Selection.Merge
  198. xlSheet.Range("A2:O15").Select()
  199. With myExcel.Selection
  200. .HorizontalAlignment = xlLeft : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  201. .ShrinkToFit = False : .ReadingOrder = xlContext
  202. End With
  203. With myExcel.Selection
  204. .HorizontalAlignment = xlLeft : .VerticalAlignment = xlTop : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  205. .ShrinkToFit = False : .ReadingOrder = xlContext
  206. End With
  207. With myExcel.Selection
  208. .HorizontalAlignment = xlLeft : .VerticalAlignment = xlTop : .WrapText = True : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  209. .ShrinkToFit = False : .ReadingOrder = xlContext
  210. End With
  211. xlSheet.Range("A2:B15,D2:E6,H2:I15,M3:M5").Select() : xlSheet.Range("M3").Activate()
  212. With myExcel.Selection.Interior
  213. .Pattern = xlSolid : .PatternColorIndex = xlAutomatic : .ThemeColor = xlThemeColorAccent4 : .TintAndShade = 0.799981688894314 : .PatternTintAndShade = 0
  214. End With
  215. xlSheet.Range("A1").Select() : myExcel.ActiveWindow.DisplayGridlines = False
  216. xlSheet.Range("D7:E7,F7:G7").Select() : xlSheet.Range("F7").Activate()
  217. With myExcel.Selection
  218. .HorizontalAlignment = xlCenter : .VerticalAlignment = xlTop : .WrapText = True : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  219. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False
  220. End With
  221. myExcel.Selection.Merge
  222. xlSheet.Range("D7:E7").Select()
  223. With myExcel.Selection.Interior
  224. .Pattern = xlSolid : .PatternColorIndex = xlAutomatic : .ThemeColor = xlThemeColorAccent4 : .TintAndShade = 0.799981688894314 : .PatternTintAndShade = 0
  225. End With
  226. xlSheet.Rows("7:7").Select : xlSheet.Rows("7:7").EntireRow.AutoFit : xlSheet.Range("F10").Select()
  227. xlSheet.Range("D7:G7").Select()
  228. With myExcel.Selection
  229. .HorizontalAlignment = xlLeft : .VerticalAlignment = xlTop : .WrapText = True : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  230. .ShrinkToFit = False : .ReadingOrder = xlContext
  231. End With
  232. xlSheet.Range("C9:D15").Select()
  233. With myExcel.Selection
  234. .HorizontalAlignment = xlGeneral : .VerticalAlignment = xlTop : .WrapText = True : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  235. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False
  236. End With
  237. myExcel.Selection.UnMerge
  238. xlSheet.Range("J8:M15").Select()
  239. With myExcel.Selection
  240. .HorizontalAlignment = xlGeneral : .VerticalAlignment = xlTop : .WrapText = True : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  241. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False
  242. End With
  243. myExcel.Selection.UnMerge
  244. xlSheet.Range("C9:E15").Select()
  245. With myExcel.Selection
  246. .HorizontalAlignment = xlCenter : .VerticalAlignment = xlTop : .WrapText = True : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  247. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False
  248. End With
  249. myExcel.Selection.Merge
  250. xlSheet.Range("J8:N15").Select()
  251. With myExcel.Selection
  252. .HorizontalAlignment = xlCenter : .VerticalAlignment = xlTop : .WrapText = True : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  253. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False
  254. End With
  255. myExcel.Selection.Merge
  256. xlSheet.Range("C9:E15").Select()
  257. With myExcel.Selection
  258. .HorizontalAlignment = xlLeft : .VerticalAlignment = xlTop : .WrapText = True : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  259. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = True
  260. End With
  261. xlSheet.Range("J8:N15").Select()
  262. With myExcel.Selection
  263. .HorizontalAlignment = xlLeft : .VerticalAlignment = xlTop : .WrapText = True : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  264. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = True
  265. End With
  266. xlSheet.Rows("8:9").Select
  267. xlSheet.Rows("8:9").EntireRow.AutoFit
  268. xlSheet.Range("C1").Select()
  269. xlApp.Application.PrintCommunication = False
  270. With xlBook.ActiveSheet.PageSetup : .PrintTitleRows = "" : .PrintTitleColumns = "" : End With
  271. xlApp.Application.PrintCommunication = True : xlBook.ActiveSheet.PageSetup.PrintArea = "" : xlApp.Application.PrintCommunication = False
  272. With xlBook.ActiveSheet.PageSetup
  273. .LeftHeader = "" : .CenterHeader = "" : .RightHeader = "" : .LeftFooter = "" : .CenterFooter = "" : .RightFooter = ""
  274. .LeftMargin = xlApp.Application.InchesToPoints(0.7) : .RightMargin = xlApp.Application.InchesToPoints(0.7)
  275. .TopMargin = xlApp.Application.InchesToPoints(0.75) : .BottomMargin = xlApp.Application.InchesToPoints(0.75)
  276. .HeaderMargin = xlApp.Application.InchesToPoints(0.3) : .FooterMargin = xlApp.Application.InchesToPoints(0.3)
  277. .PrintHeadings = False : .PrintGridlines = False : .CenterHorizontally = False : .CenterVertically = False : .Draft = False
  278. .FirstPageNumber = xlAutomatic : .BlackAndWhite = False : .Zoom = 100 : .OddAndEvenPagesHeaderFooter = False : .DifferentFirstPageHeaderFooter = False
  279. .ScaleWithDocHeaderFooter = True : .AlignMarginsHeaderFooter = True : .EvenPage.LeftHeader.Text = "" : .EvenPage.CenterHeader.Text = ""
  280. .EvenPage.RightHeader.Text = "" : .EvenPage.LeftFooter.Text = "" : .EvenPage.CenterFooter.Text = "" : .EvenPage.RightFooter.Text = ""
  281. .FirstPage.LeftHeader.Text = "" : .FirstPage.CenterHeader.Text = "" : .FirstPage.RightHeader.Text = "" : .FirstPage.LeftFooter.Text = ""
  282. .FirstPage.CenterFooter.Text = "" : .FirstPage.RightFooter.Text = ""
  283. End With
  284. xlApp.Application.PrintCommunication = True : xlApp.Application.PrintCommunication = False
  285. With xlBook.ActiveSheet.PageSetup : .PrintTitleRows = "" : .PrintTitleColumns = "" : End With
  286. xlApp.Application.PrintCommunication = True : xlBook.ActiveSheet.PageSetup.PrintArea = "" : xlApp.Application.PrintCommunication = False
  287. With xlBook.ActiveSheet.PageSetup
  288. .LeftHeader = "" : .CenterHeader = "" : .RightHeader = "" : .LeftFooter = "" : .CenterFooter = "" : .RightFooter = ""
  289. .LeftMargin = xlApp.Application.InchesToPoints(0.708661417322835) : .RightMargin = xlApp.Application.InchesToPoints(0.708661417322835)
  290. .TopMargin = xlApp.Application.InchesToPoints(0.748031496062992) : .BottomMargin = xlApp.Application.InchesToPoints(0.748031496062992)
  291. .HeaderMargin = xlApp.Application.InchesToPoints(0.31496062992126) : .FooterMargin = xlApp.Application.InchesToPoints(0.31496062992126)
  292. .PrintHeadings = False : .PrintGridlines = False : .CenterHorizontally = False : .CenterVertically = False : .Draft = False
  293. .FirstPageNumber = xlAutomatic : .BlackAndWhite = False : .Zoom = False : .FitToPagesWide = 1 : .FitToPagesTall = 1
  294. .OddAndEvenPagesHeaderFooter = False : .DifferentFirstPageHeaderFooter = False : .ScaleWithDocHeaderFooter = True : .AlignMarginsHeaderFooter = True
  295. .EvenPage.LeftHeader.Text = "" : .EvenPage.CenterHeader.Text = "" : .EvenPage.RightHeader.Text = "" : .EvenPage.LeftFooter.Text = ""
  296. .EvenPage.CenterFooter.Text = "" : .EvenPage.RightFooter.Text = "" : .FirstPage.LeftHeader.Text = "" : .FirstPage.CenterHeader.Text = ""
  297. .FirstPage.RightHeader.Text = "" : .FirstPage.LeftFooter.Text = "" : .FirstPage.CenterFooter.Text = "" : .FirstPage.RightFooter.Text = ""
  298. End With
  299. xlApp.Application.PrintCommunication = True : xlApp.Application.PrintCommunication = False
  300. With xlBook.ActiveSheet.PageSetup : .PrintTitleRows = "" : .PrintTitleColumns = "" : End With
  301. xlApp.Application.PrintCommunication = True : xlBook.ActiveSheet.PageSetup.PrintArea = "" : xlApp.Application.PrintCommunication = False
  302. With xlBook.ActiveSheet.PageSetup
  303. .LeftHeader = "" : .CenterHeader = "" : .RightHeader = "" : .LeftFooter = "" : .CenterFooter = "" : .RightFooter = ""
  304. .LeftMargin = xlApp.Application.InchesToPoints(0.25) : .RightMargin = xlApp.Application.InchesToPoints(0.25)
  305. .TopMargin = xlApp.Application.InchesToPoints(0.75) : .BottomMargin = xlApp.Application.InchesToPoints(0.75)
  306. .HeaderMargin = xlApp.Application.InchesToPoints(0.3) : .FooterMargin = xlApp.Application.InchesToPoints(0.3)
  307. .PrintHeadings = False : .PrintGridlines = False : .CenterHorizontally = False : .CenterVertically = False : .Draft = False
  308. .FirstPageNumber = xlAutomatic : .BlackAndWhite = False : .Zoom = False : .FitToPagesWide = 1 : .FitToPagesTall = 1
  309. .OddAndEvenPagesHeaderFooter = False : .DifferentFirstPageHeaderFooter = False : .ScaleWithDocHeaderFooter = True : .AlignMarginsHeaderFooter = True
  310. .EvenPage.LeftHeader.Text = "" : .EvenPage.CenterHeader.Text = "" : .EvenPage.RightHeader.Text = "" : .EvenPage.LeftFooter.Text = ""
  311. .EvenPage.CenterFooter.Text = "" : .EvenPage.RightFooter.Text = "" : .FirstPage.LeftHeader.Text = "" : .FirstPage.CenterHeader.Text = ""
  312. .FirstPage.RightHeader.Text = "" : .FirstPage.LeftFooter.Text = "" : .FirstPage.CenterFooter.Text = "" : .FirstPage.RightFooter.Text = ""
  313. End With
  314. xlApp.Application.PrintCommunication = True : xlBook.ActiveSheet.PageSetup.Orientation = 2
  315. xlBook.ActiveSheet.PageSetup.CenterFooter = OD(18) & "-" & OD(0)
  316. xlSheet.Range("M6:N6").Select()
  317. With myExcel.Selection
  318. .HorizontalAlignment = xlCenter : .VerticalAlignment = xlTop : .WrapText = True : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  319. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False
  320. End With
  321. myExcel.Selection.Merge
  322. xlSheet.Rows("6:6").Select : xlSheet.Range("O6").Activate() : myExcel.Selection.RowHeight = 12.75
  323. xlSheet.Range("O7").Select()
  324. End Sub
  325. End Class