【问题标题】:Add box around text for Excel to Powerpoint VBA将 Excel 的文本框添加到 Powerpoint VBA
【发布时间】:2018-12-04 23:52:15
【问题描述】:

我正在将数据从 Excel 导入到 Powerpoint 幻灯片中。我如何能够在文本框周围添加一个框/轮廓?还有什么方法可以添加一个不会移动的静态轮廓,即使我要从中导入的单元格中没有文本?

感谢您的所有帮助!

这是我的代码的 sn-p:

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

【问题讨论】:

  • 这可能没有帮助,但是当我在Powerpoint幻灯片中显示Excel中的数据和图表时,我通常先将它们复制到Paint中,然后将图像复制并粘贴到幻灯片中。这会将其粘贴为实际图像,而不是嵌入的 Excel 对象,这会使我的演示变得臃肿。
  • @Martin Parkin 我有一个宏,它从超过 200 行 Excel 数据中获取数据并将其更新到 Powerpoint 中,因此很遗憾,我无法复制和粘贴图像。不过还是谢谢!! :)

标签: excel vba powerpoint outline


【解决方案1】:

TextFrame 或 TextRange 没有边框元素。 父 'Shape' 可以有这样的边框。

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

【讨论】:

    猜你喜欢
    • 2015-07-27
    • 2017-04-15
    • 2022-01-22
    • 1970-01-01
    • 1970-01-01
    • 2015-07-26
    • 2014-06-13
    • 2015-03-18
    • 1970-01-01
    相关资源
    最近更新 更多