【问题标题】:PPT VBA auto-select new textbox?PPT VBA自动选择新文本框?
【发布时间】:2017-03-29 03:57:43
【问题描述】:

我有一个宏来创建一个带有某些参数的新文本框,但是当它创建时,我仍然需要点击它(然后使用“Enter”作为键盘快捷键来突出显示文本并开始输入)。 我想知道是否有一种方法可以在我运行宏后立即选择文本框,甚至更好的是,是否有一种方法可以自动突出显示测试文本(这样添加框和输入之间就没有步骤)。

以下代码(从The Spreadsheet Guru 复制并稍作修改)。

Dim Sld As Slide
Dim Shp As Shape

'ERROR HANDLING
If ActivePresentation.Slides.Count = 0 Then
    MsgBox "You do not have any slides in your PowerPoint project."
    Exit Sub
End If

Set Sld = Application.ActiveWindow.View.Slide

'Create shape with Specified Dimensions and Slide Position
Set Shp = Sld.Shapes.AddTextbox(Orientation:=msoTextOrientationHorizontal,      Left:=24, Top:=65.6, Width:=300, Height:=100)

'FORMAT SHAPE
'No Shape Border
    Shp.Line.Visible = msoFalse

'Shape Fill Color
    Shp.Fill.Visible = msoFalse

'Shape Text Color
    Shp.TextFrame.TextRange.Font.Color.RGB = RGB(0, 0, 0)

'Text inside Shape
    Shp.TextFrame.TextRange.Characters.Text = "Text"

'Center Align Text
    Shp.TextFrame.TextRange.Paragraphs.ParagraphFormat.Alignment = ppAlignLeft

'Vertically Align Text to Middle
    Shp.TextFrame2.VerticalAnchor = msoAnchorTop

'Adjust Font Size
    Shp.TextFrame2.TextRange.Font.Size = 12

'Adjust Font Style
    Shp.TextFrame2.TextRange.Font.Name = "Arial"

谢谢!

【问题讨论】:

    标签: vba powerpoint


    【解决方案1】:

    在末尾添加这一行:

     Shp.TextFrame.TextRange.Select
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-08-16
      • 2011-02-08
      • 2015-11-17
      • 2022-06-10
      相关资源
      最近更新 更多