|
添加表注演示图
- Sub 本科论文表注设置()
- Application.StatusBar = "开始添加表注……"
- Set MyDoc = ActiveDocument
- Set MyTables = MyDoc.Tables
- t_sum = MyTables.Count
- b = False
- If t_sum > 0 Then
- For Each MyStyle In MyDoc.Styles
- If MyStyle.NameLocal = "表注" Then
- b = True
- Exit For
- Else
- b = False
- End If
- Next
- CaptionLabels.Add Name:="表"
- For Each MyTable In MyTables
- ' 如果表格为无框线表格
- If MyTable.Borders(wdBorderLeft).LineStyle <> wdLineStyleNone Or MyTable.Borders(wdBorderRight).LineStyle <> wdLineStyleNone Or _
- MyTable.Borders(wdBorderTop).LineStyle <> wdLineStyleNone Or MyTable.Borders(wdBorderBottom).LineStyle <> wdLineStyleNone Or _
- MyTable.Borders(wdBorderHorizontal).LineStyle <> wdLineStyleNone Or MyTable.Borders(wdBorderVertical).LineStyle <> wdLineStyleNone Or _
- MyTable.Borders(wdBorderDiagonalDown).LineStyle <> wdLineStyleNone Or MyTable.Borders(wdBorderDiagonalUp).LineStyle <> wdLineStyleNone Then
- ' 检测表格上一段落文字是否包含表注
- MyTable.Select
- Selection.Move unit:=wdParagraph, Count:=-2
- Selection.Expand unit:=wdParagraph
- If Selection.Range Like "表*#*" And Len(Trim(Selection.Range)) <= 20 Then
- If b = True Then
- Selection.Range.Style = "表注"
- Else
- Selection.Range.Style = "题注"
- MyStr = "(表注采用默认样式)"
- End If
- Else
- ' 检测表格下一段落文字是否包含表注
- MyTable.Select
- Selection.Move unit:=wdParagraph, Count:=1
- Selection.Expand unit:=wdParagraph
- If Selection.Range Like "表*#*" And Len(Trim(Selection.Range)) < 20 Then
- If b = True Then
- Selection.Range.Style = "表注"
- Else
- Selection.Range.Style = "题注"
- MyStr = "(表注采用默认样式)"
- End If
- Else
- MyTable.Select
- Selection.Move unit:=wdParagraph, Count:=-2
- Selection.InsertCaption Label:="表", TitleAutoText:="", Title:="", Position _
- :=wdCaptionPositionAbove, ExcludeLabel:=0
- End If
- End If
- End If
- Next
- Application.StatusBar = "表注添加完毕,请检查!" & MyStr
- Else
- Application.StatusBar = "本文没有表格"
- End If
- End Sub
复制代码
|
评分
-
1
查看全部评分
-
|