|
经测试,仅替换段落缩进确实替换不了,此处提供以下面两种方法:
方法一、Word VBA代码
(代码也可以用替换,此处就用其他方法了)
- Function 纯文本(ByVal myString As String) As String
- Dim s As String
-
- s = myString
- s = Replace(s, " ", "")
- s = Replace(s, " ", "")
- s = Replace(s, vbTab, "")
- s = Replace(s, Chr(7), "")
- s = Replace(s, Chr(11), "")
- s = Replace(s, Chr(13), "")
- s = Replace(s, Chr(160), "")
-
- 纯文本 = s
- End Function
- Sub 图片段居中()
- Dim pa As Paragraph
- Dim ispCount As Integer
- Dim lenTrim As Integer
- For Each pa In ActiveDocument.Paragraphs
- ispCount = pa.Range.InlineShapes.Count
- If ispCount > 0 Then
- lenTrim = Len(纯文本(pa.Range.Text))
- If ispCount = lenTrim Then
- With pa.Range
- .Style = pa.Range.Document.Styles("正文") '设置样式为正文以免影响其他位置格式,可省
- .ParagraphFormat.CharacterUnitFirstLineIndent = 0 '设置首行字符缩进为0
- .ParagraphFormat.FirstLineIndent = 0 '设置首先缩进0磅
- .ParagraphFormat.Alignment = wdAlignParagraphCenter '图片居中
- End With
- End If
- End If
- Next
- End Sub
复制代码
▼
|
|