EXCEL vba 如何更改文档属性,如标题、作者等

2024-12-04 22:48:09
推荐回答(3个)
回答1:

  下面是VBA代码功能:

  1. 当前文档的上面添加文字dzwebs文字。

  2. 然后,又设置第一段居中对齐,并在该段落之后添加半英寸的间距。将dzwebs的格式设为36磅,隶书字体。

  Dim rngFormat As Range
  Set rngFormat = ActiveDocument.Range(Start:=0, End:=0)
    With rngFormat
        .InsertAfter Text:="dzwebs"
        .InsertParagraphAfter
        With .Font
            .Name = "隶书"
            .Size = 36
            .Bold = True
        End With
    End With
    With ActiveDocument.Paragraphs(1)
        .Alignment = wdAlignParagraphCenter
        .SpaceAfter = InchesToPoints(0.5)
    End With


  部分代码解释:

  Dim rngFormat As Range 定义变量

  Set rngFormat = ActiveDocument.Range(Start:=0, End:=0) 设置rngFormat变量的位置,位于文档的最上面

  With rngFormat
    里面的代码功能是设置字体字号等属性
  End With

  With ActiveDocument.Paragraphs(1)
        .Alignment = wdAlignParagraphCenter
        .SpaceAfter = InchesToPoints(0.5)
  End With
  该代码代码功能是添加段后距离为0.5英寸

回答2:

你新建一个EXCEL在桌面上,不打开,鼠标点击右键,找到“属性”点击进入后找到”摘要“里面就可以更改了,希望能帮助你!

回答3:

我录制出来的有(选中图表中的标题,通过工具栏上的字号直接更改的)。
ActiveSheet.ChartObjects("Chart 2").Activate
ActiveChart.ChartTitle.Select
Selection.Characters.Text = "Test for LifeDebug"
Selection.AutoScaleFont = False
With Selection.Characters(Start:=1, Length:=18).Font
.Name = "宋体"
.FontStyle = "Regular"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With