我有一个宏来创建一个带有某些参数的新文本框,但是当它被创建时,我仍然需要单击它(然后使用“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"
谢谢!
答案 0 :(得分:1)
在最后添加此行:
Shp.TextFrame.TextRange.Select