|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
楼主,第二个表格,请将表头删除,处理成第一个表格的样式就可以和第一个表格一样使用宏了!
- Sub a0000_0317_RotateText()
- Dim t As Table, c As Cell, i&, j&, s$
-
- Set t = ActiveDocument.Tables(1)
-
- For Each c In t.Range.Cells
- c.Range.Orientation = wdTextOrientationUpward
- Next
- t.Rows.Height = CentimetersToPoints(0.9)
- t.Rows(2).Select
- Selection.Range.Relocate wdRelocateUp
- j = 1
- Do
- ActiveDocument.Tables(2).Select
-
- With Selection
- If .Rows.Count = 1 Then
- .Range.Relocate wdRelocateUp
- .Range.Relocate wdRelocateDown
- Exit Do
- End If
-
- i = 2
- j = j + 1
- .Tables(1).Rows(i).Select
-
- For i = 1 To j
- .Range.Relocate wdRelocateUp
- Next
- End With
- Loop
-
- t.Rows(t.Rows.Count).Height = CentimetersToPoints(1.6)
- t.Columns(1).Select
-
- With Selection
- .InsertColumns
- .Cells.Merge
- .ParagraphFormat.Alignment = wdAlignParagraphCenter
- .Cells.VerticalAlignment = wdCellAlignVerticalCenter
- End With
-
- t.Select
- s = Selection.Previous(4, 1)
- s = Replace(s, vbCr, "")
- With t
- .Cell(1, 1).Range.Text = s
- .AutoFitBehavior (wdAutoFitContent)
- .Select
- .AutoFitBehavior (wdAutoFitWindow)
- .Range.Font.ColorIndex = wdRed
- End With
- End Sub
复制代码 |
|