爱问知识人 爱问教育 医院库

一级标题缩进设置为0字符不起作用?office-word-宏

首页

一级标题缩进设置为0字符不起作用?office-word-宏

以下宏对一级标题的颜色与字体能起作用,但对首行缩进不起作用。
能否修改一下宏,如何运行宏一级标题的缩进设置为0字符? office word 宏

Sub 一级标题缩进设置为0()
With Selection.Find
    .ClearFormatting '清除格式
    .Style = ActiveDocument.Styles(wdStyleHeading1)  '查找标题 1 
    .Wrap = wdFindContinue '找到尾后重头找
    .Text = ""
    .Replacement.ClearFormatting
    .Replacement.Text = ""
    .Replacement.Font.Color = vbBlue               ‘颜色为蓝色
    .Replacement.ParagraphFormat.CharacterUnitFirstLineIndent = 0  '1级标题缩进设置为0
    .Execute Replace:=wdReplaceAll '全部替换
End With
End Sub

以下宏对一级标题的颜……
提交回答
好评回答
  • 2010-10-11 14:46:57
      Sub 前123级标题()  '测试结果 1 代码重复运行1次才能调整好。
    Selection。HomeKey wdStory '光标移到最前面。
    Dim p As Paragraph
     For Each p In ActiveDocument。
      Paragraphs If p。Style = "标题 1" Then p。LeftIndent = 0 '段落的绝对左缩进量(以磅为单位) If p。Style = "标题 1" Then p。
      RightIndent = 0 '段落的绝对左缩进量(以磅为单位) If p。Style = "标题 1" Then p。FirstLineIndent = CentimetersToPoints(0) '首行缩进0cm(只对单位是cm的缩进有效) If p。
      Style = "标题 1" Then p。CharacterUnitFirstLineIndent = 0 '首行缩进0磅(只对单位是磅的缩进有效) If p。Style = "标题 2" Then p。
      LeftIndent = 0 '段落的绝对左缩进量(以磅为单位) If p。Style = "标题 2" Then p。RightIndent = 0 '段落的绝对左缩进量(以磅为单位) If p。
      Style = "标题 2" Then p。FirstLineIndent = CentimetersToPoints(0) '首行缩进0cm(只对单位是cm的缩进有效) If p。Style = "标题 2" Then p。CharacterUnitFirstLineIndent = 0 '首行缩进0磅(只对单位是磅的缩进有效) If p。
      Style = "标题 3" Then p。LeftIndent = 0 '段落的绝对左缩进量(以磅为单位) If p。Style = "标题 3" Then p。RightIndent = 0 '段落的绝对左缩进量(以磅为单位) If p。
      Style = "标题 3" Then p。FirstLineIndent = CentimetersToPoints(0) ' '首行缩进0cm If p。Style = "标题 3" Then p。CharacterUnitFirstLineIndent = 0 '首行缩进0磅(只对单位是磅的缩进有效) If p。
      Style = "标题 1" Then p。FirstLineIndent = CentimetersToPoints(0) '首行缩进0cm(只对单位是cm的缩进有效) If p。Style = "标题 1" Then p。CharacterUnitFirstLineIndent = 0 '首行缩进0磅(只对单位是磅的缩进有效) If p。
      Style = "标题 2" Then p。FirstLineIndent = CentimetersToPoints(0) '首行缩进0cm(只对单位是cm的缩进有效) If p。Style = "标题 2" Then p。CharacterUnitFirstLineIndent = 0 '首行缩进0磅(只对单位是磅的缩进有效) If p。
      Style = "标题 3" Then p。FirstLineIndent = CentimetersToPoints(0) ' '首行缩进0cm If p。Style = "标题 3" Then p。CharacterUnitFirstLineIndent = 0 '首行缩进0磅(只对单位是磅的缩进有效) Next Selection。
      Move ' If p。Style = "标题 1" Then p。Range。Font。Color = vbBlack 'blue ' If p。Style = "标题 1" Then p。
      Format。LineSpacingRule = wdLineSpaceExactly '行距固定值 ' If p。Style = "标题 1" Then p。Format。LineSpacing = 20 '行距固定值= 20 ' If p。
      Style = "标题 1" Then p。Format。SpaceBefore = 0 '段前距为0 ' If p。Style = "标题 1" Then p。Format。SpaceAfter = 0 '段后距为0 ' If p。
      Style = "标题 1" Then p。LeftIndent = 0 '段落的绝对左缩进量(以磅为单位) ' If p。Style = "标题 1" Then p。RightIndent = 0 '段落的绝对右缩进量(以磅为单位) ' If p。
      Style = "标题 1" Then p。Range。Bold = True '加粗 ' If p。Style = "标题 1" Then p。CharacterUnitFirstLineIndent = InchesToPoints(0) '度量单位从英寸转换为磅Points Selection。
      HomeKey wdStory '光标移到最前面。' D图片居中 End Sub。

    f***

    2010-10-11 14:46:57

其他答案

    2010-10-09 16:50:32
  • 用下面这段宏试试吧!
    Option Explicit
    Sub 一级标题缩进设置为0()
    With Selection.Find
      .ClearFormatting
      .Style = ActiveDocument.Styles(wdStyleHeading1)
      .Forward = True
      Do
        .Execute
        Selection.ParagraphFormat.CharacterUnitFirstLineIndent = 0
        Selection.ParagraphFormat.FirstLineIndent = 0
      Loop While Len(Selection.Text) > 1
    End With
    End Sub
    

    è***

    2010-10-09 16:50:32

  • 2010-10-05 15:46:51
  • 我不懂宏。其实我经常编辑文档,都是一些格式性的东西。比如,一级标题的设置,二级,三级的设置。但不知道有没有某种方式,可以规范化的来一次性设置这些东东?

    c***

    2010-10-05 15:46:51

类似问题

换一换
  • 办公软件 相关知识

  • 电脑网络技术
  • 电脑网络

相关推荐

正在加载...
最新资料 推荐信息 热点推荐
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200

热点检索

  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
返回
顶部
帮助 意见
反馈

确定举报此问题

举报原因(必选):