下面是我用来将图表从 excel 电子表格中提取到 ppt 中的过程。但是我无法弄清楚的一件事是如何将图片插入“对象”而不是仅仅将其粘贴到屏幕上。(即,如果我做了一个 ppLayoutFourObjects,并将四个图表发送到这张幻灯片,在添加另一个之前,我需要知道如何将图表粘贴到从 4 个对象选择中显示的每个指定矩形中)。我知道第一个似乎总是矩形五,我无法正确获取代码。请帮忙。这都是2003 Office。
sub xls2ppt()
'I use this to pull charts into ppt from excel
Dim xlApp As Object
Dim xlWrkBook As Object
Dim lCurrSlide As Long
Set xlApp = CreateObject("Excel.Application")
' Open the Excel workbook
Set xlWrkBook = xlApp.Workbooks.Open("X:\Users\Admin\Desktop\Budget Overview.xls")
' Copy picture of the 1st chart object onto the clipboard
xlWrkBook.Worksheets(2).ChartObjects(1).CopyPicture
' Get the slide number
lCurrSlide = ActiveWindow.Selection.SlideRange.SlideNumber
' Paste the picture onto the PowerPoint slide.
ActivePresentation.Slides(lCurrSlide).Shapes.Paste
' Close the open workbook without saving changes
xlWrkBook.Close (False)
xlApp.Quit
Set xlApp = Nothing
Set xlWrkBook = Nothing
End Sub
谢谢你的帮助。PowerPoint 的 VBA 是我最弱的,但我真的需要拿起它来工作!多谢你们!