下面是一個用於從EXCEL電子表格中將圖表拖入ppt的過程。但是我無法弄清楚的一件事是如何將圖片插入到「對象」中,而不是將其粘貼到屏幕上。 (即,如果我做了一個ppLayoutFourObjects,並且在添加另一個幻燈片之前發送了四輪圖表,我需要知道如何將圖表粘貼到從4個對象選項中顯示的每個指定矩形中)。我知道,第一個似乎總是矩形五,我不能得到正確的代碼。請幫忙。 這是所有2003 Office。用於將圖表插入ppt幻燈片的VBA
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是我最弱的,但我真的需要爲它工作!多謝你們!
是矩形佔位符?如果是這樣,我相信如果您在粘貼前選擇佔位符,圖表將被粘貼到佔位符中。 (我仍然在爲我自己的項目研究這個細節。) – 2017-09-23 14:48:05