我正在将数据从Excel导入到Powerpoint幻灯片中。我如何能够在文本框周围添加框/轮廓?还有什么方法可以添加不会移动的静态轮廓,即使我要导入的单元格中没有文本也是如此?
感谢您提供的所有帮助!
以下是我的代码段:
Set ppSlide2 = ppPres.Slides.Add(i + 1, ppLayoutBlank).Shapes
Set HeaderPPT = ppSlide2.AddTextbox(msoTextOrientationHorizontal, 75, 150, 800, 700).TextFrame.TextRange
If Sheet1.Range("P" & RowExcel).Text = "Title" Then
With HeaderPPT
.Text = vbNewLine & Cells(RowExcel, col + 9)
.ParagraphFormat.Alignment = ppAlignCenter
.Font.Bold = True
.Font.Name = "Calibri Light"
.Font.Size = 55
End With
End If
答案 0 :(得分:0)
TextFrame或TextRange没有边框元素。 父级“形状”可以具有这样的边框。
Dim sld as Slide, shp as Shape
Set sld = Activepresentation.Slides(1)
Set shp = sld.Shapes.AddShapes(msoShapeRectangle, 100,100,100,100)
With shp
.Line.Visible = True
.Line.Weight = 2
.Line.ForeColor.RGB = RGB(255,0,0)
End with
要放置静态边框,我想您可以先添加一个矩形或TextBox。 然后再次添加带有Excel单元格内容的TextBox。 (但是,如果使用AddTextBox添加一个Textbox,则形状的边框默认情况下是静态的,即使其中没有文本也是如此。)
无论如何,我测试了以下代码:
Set ppSlide2 = ActivePresentation.Slides.Add(ActivePresentation.Slides.Count, ppLayoutBlank).Shapes
'first, add a box(rectangle) or textbox so that the z-order can be lower than the next Textbox
Set HeaderBOX = ppSlide2.AddShape(msoShapeRectangle, 75, 150, 800, 700)
'or Set HeaderBOX = ppSlide2.AddTextbox(msoTextOrientationHorizontal, 75, 150, 800, 700)
With HeaderBOX
.Name = "HeaderBOX"
.Fill.Visible = False 'make it transparent
.Line.Visible = True
.Line.ForeColor.RGB = rgbBlack 'RGB(0,0,0)
.Line.Weight = 2
End With
'then, add a textbox
Set HeaderPPT = ppSlide2.AddTextbox(msoTextOrientationHorizontal, 75, 150, 800, 700).TextFrame.TextRange
With HeaderPPT
.Text = vbNewLine & "Excel Cell Text Here"
.ParagraphFormat.Alignment = ppAlignCenter
.Font.Bold = True
.Font.Name = "Calibri Light"
.Font.Size = 55
End With