我使用以下代码将excel屏幕截图导出到powerpoint
Sub ExcelRangeToPowerPoint()
'PURPOSE: Copy/Paste An Excel Range Into a New PowerPoint Presentation
'SOURCE: www.TheSpreadsheetGuru.com
Dim rng As Range
Dim PowerPointApp As Object
Dim myPresentation As Object
Dim mySlide As Object
Dim myShape As Object
'Copy Range from Excel
Set rng = Worksheets("Overall").Range("B2:AH47")
'Create an Instance of PowerPoint
On Error Resume Next
'Is PowerPoint already opened?
Set PowerPointApp = GetObject(class:="PowerPoint.Application")
'Clear the error between errors
Err.Clear
'If PowerPoint is not already open then open PowerPoint
If PowerPointApp Is Nothing Then Set PowerPointApp = CreateObject(class:="PowerPoint.Application")
'Handle if the PowerPoint Application is not found
If Err.Number = 429 Then
MsgBox "PowerPoint could not be found, aborting."
Exit Sub
End If
On Error GoTo 0
'Optimize Code
Application.ScreenUpdating = False
'Create a New Presentation
Set myPresentation = PowerPointApp.Presentations.Add
'Add a slide to the Presentation
Set mySlide = myPresentation.Slides.Add(1, 11) '11 = ppLayoutTitleOnly
'Copy Excel Range
rng.Copy
'Paste to PowerPoint and position
mySlide.Shapes.PasteSpecial DataType:=2 '2 = ppPasteEnhancedMetafile
Set myShape = mySlide.Shapes(mySlide.Shapes.Count)
'Set position:
myShape.Left = 35
myShape.Top = 15
'setting size
myShape.Height = 510
'Make PowerPoint Visible and Active
PowerPointApp.Visible = True
PowerPointApp.Activate
'Clear The Clipboard
Application.CutCopyMode = False
End Sub
并向ppt投放截图,如下所示:
所有红色方框都显示白色的文字。在excel中查看时它们是隐藏的,但只有在选择屏幕捕获并导出到ppt
时才会出现请帮忙!
答案 0 :(得分:0)
该问题与在透明背景上的元文件中呈现文本有关。有两种方法可以解决这个问题:
rng.CopyPicture xlScreen, xlBitmap
将Excel范围复制为位图。由于位图格式不支持透明度,因此单元格背景将自动呈现为白色。此选项的缺点是复制的范围不再能够很好地扩展,因为它不再是矢量格式。rng.CopyPicture xlPrinter, XlPicture
复制范围。使用此选项时,您仍然可以在PowerPoint中使用可缩放的图元文件。