打印本文 打印本文 关闭窗口 关闭窗口
使用VBA给Excel自选图形添加文字的代码
作者:武汉SEO闵涛  文章来源:敏韬学习网  点击数2962  更新时间:2010/6/21 21:22:50  文章录入:mintao  责任编辑:mintao

  使用如下的代码,可以给Excel中插入的自选图形动态添加文字。以下代码是示例代码,请根据需要加以修改并利用。

  代码如下:

  Dim sh As Shape
  Set sh = Sheet1.Shapes.AddShape(msoShapeHexagon, 120, 120, 40, 10 * Sqr(3))
  sh.TextFrame.Characters.Text = "这里就填写自选图形的文字"
      With sh.TextFrame.Characters.Font
          .Name = "宋体"
          .FontStyle = "倾斜"
          .Size = 9
          .Strikethrough = False
          .Superscript = False
          .Subscript = False
          .OutlineFont = False
          .Shadow = False
          .Underline = xlUnderlineStyleNone
          .ColorIndex = 3
      End With
      With sh.TextFrame
          .HorizontalAlignment = xlCenter
          .VerticalAlignment = xlCenter
          .ReadingOrder = xlContext
          .AutoSize = False
      End With

打印本文 打印本文 关闭窗口 关闭窗口