admin管理员组文章数量:1122847
【vba
Sub addTz()Word.Application.ScreenUpdating = FalseDim oRng As RangeDim oDoc As DocumentDim oCL As CaptionLabelDim oIS As InlineShapeSet oDoc = Word.ActiveDocumentWith oDocSet oCL = Word.CaptionLabels.Add("图")'设置新增的题注样式With oCL.ChapterStyleLevel = 1.IncludeChapterNumber = True.NumberStyle = wdCaptionNumberStyleArabicEnd Withi = 1For Each oIS In .InlineShapesSet 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, ioRng.Expand wdParagraph.SetRange .Start, .Start.InsertBefore sText & "如"End Withi = i + 1NextEnd WithWord.Application.ScreenUpdating = True
End Sub
本文标签: VBA
版权声明:本文标题:【vba 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/biancheng/1707035944a709636.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论