Sub addTz()
Word.Application.ScreenUpdating = False
Dim oRng As Range
Dim oDoc As Document
Dim oCL As CaptionLabel
Dim oIS As InlineShape
Set oDoc = Word.ActiveDocument
With oDoc
Set oCL = Word.CaptionLabels.Add("图")
'设置新增的题注样式
With oCL
.ChapterStyleLevel = 1
.IncludeChapterNumber = True
.NumberStyle = wdCaptionNumberStyleArabic
End With
i = 1
For Each oIS In .InlineShapes
Set oRng = .Range(oIS.Range.End + 1, oIS.Range.End + 1)
With oRng
'防止影响下段格式
.InsertAfter (vbCrLf)
'将oRng对象按照整个段落选中,oRng对象自动变为整个段落的Range对象
oRng.Expand wdParagraph
'如果有自动编号 删除
oRng.ListFormat.RemoveNumbers
'读取标题的文本内容
sText = VBA.Replace(oRng.Text, Chr(13), "")
.Delete
'插入题注
.InsertCaption "图", sText
'插入xx如yy所示的交叉引用
.InsertAfter "所示" & Chr(13)
'重新定义区域
.SetRange .Start, .Start
.InsertCrossReference "图", wdOnlyLabelAndNumber, i
oRng.Expand wdParagraph
.SetRange .Start, .Start
.InsertBefore sText & "如"
End With
i = i + 1
Next
End With
Word.Application.ScreenUpdating = True
End Sub
【vba-3】vba操作word所有表格居中
原文作者:_w_q_f
原文地址: https://blog.csdn.net/u013305830/article/details/120065395
本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
原文地址: https://blog.csdn.net/u013305830/article/details/120065395
本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。