文本格式:设置阴影和倒影

使用Font对象的TextShadow属性返回一个ShadowFormat对象,利用该对象的属性进行字体阴影设置。给字体添加阴影,可以使字体呈现立体效果。

下面在打开的文档中定义一个字符序列,设置字符序列中的文本字体大小为40,加粗,颜色为红色。

code.vba
Sub Test()
  Dim doc As Document
  Set doc = Documents.Open("D:\test2.docx")
  Dim rng As Range
  Set rng = doc.Range(Start:=26, End:=34)
  rng.Font.Size = 40
  rng.Font.Bold = True
  rng.Font.TextColor.RGB = 255

  Dim shw As ShadowFormat
  Set shw = rng.Font.TextShadow
  shw.Visible = True
  shw.OffsetX = 6
  shw.OffsetY = 5

  Dim ref As ReflectionFormat
  Set ref = rng.Font.Reflection
  ref.Type = msoReflectionType8
  ref.Blur = 9
  ref.Offset = 9
  ref.Size = 90
End Sub

设置效果如图3-16所示。

Document Image

图3-16 字符序列中文本最初的显示效果