標題:
[發問]
excel 自動轉換 PPT
[打印本頁]
作者:
xperia0603
時間:
2013-10-11 11:34
標題:
excel 自動轉換 PPT
小弟有點小麻煩
VBA 目前有借幾本書來看
可是最多都介紹提升效率的方法
-
想請問一下 如何 用 Excel 的 vba 自動轉換成 ppt
是否能轉 ? 還是不能轉 ?
請求大大們對我這位vba新手介紹一下
作者:
genes
時間:
2013-10-17 02:15
回復
1#
xperia0603
請參考以下vba
Sub CreatePowerPoint()
'Add a reference to the Microsoft PowerPoint Library by:
'1. Go to Tools in the VBA menu
'2. Click on Reference
'3. Scroll down to Microsoft PowerPoint X.0 Object Library, check the box, and press Okay
'First we declare the variables we will be using
Dim newPowerPoint As PowerPoint.Application
Dim activeSlide As PowerPoint.Slide
Dim cht As Excel.ChartObject
'Look for existing instance
On Error Resume Next
Set newPowerPoint = GetObject(, "PowerPoint.Application")
On Error GoTo 0
'Let's create a new PowerPoint
If newPowerPoint Is Nothing Then
Set newPowerPoint = New PowerPoint.Application
End If
'Make a presentation in PowerPoint
If newPowerPoint.Presentations.Count = 0 Then
newPowerPoint.Presentations.Add
End If
'Show the PowerPoint
newPowerPoint.Visible = True
'Loop through each chart in the Excel worksheet and paste them into the PowerPoint
For Each cht In ActiveSheet.ChartObjects
'Add a new slide where we will paste the chart
newPowerPoint.ActivePresentation.Slides.Add newPowerPoint.ActivePresentation.Slides.Count + 1, ppLayoutText
newPowerPoint.ActiveWindow.View.GotoSlide newPowerPoint.ActivePresentation.Slides.Count
Set activeSlide = newPowerPoint.ActivePresentation.Slides(newPowerPoint.ActivePresentation.Slides.Count)
'Copy the chart and paste it into the PowerPoint as a Metafile Picture
cht.Select
ActiveChart.ChartArea.Copy
activeSlide.Shapes.PasteSpecial(DataType:=ppPasteMetafilePicture).Select
'Set the title of the slide the same as the title of the chart
activeSlide.Shapes(1).TextFrame.TextRange.Text = cht.Chart.ChartTitle.Text
'Adjust the positioning of the Chart on Powerpoint Slide
newPowerPoint.ActiveWindow.Selection.ShapeRange.Left = 15
newPowerPoint.ActiveWindow.Selection.ShapeRange.Top = 125
activeSlide.Shapes(2).Width = 200
activeSlide.Shapes(2).Left = 505
Next
AppActivate ("Microsoft PowerPoint")
Set activeSlide = Nothing
Set newPowerPoint = Nothing
End Sub
複製代碼
作者:
c_c_lai
時間:
2013-10-17 06:47
回復
1#
xperia0603
在應用 genes 樓主的 CreatePowerPoint() 函示時,記得要先開啟
Microsoft PowerPoint 14.0 Object Library (2007 版本以上)
如果不知如何啟動,請看以下說明:
開發人員 ---> 設定引用項目 ---> 勾選
"Microsoft PowerPoint 14.0 Object Library" --->
確定。
作者:
xperia0603
時間:
2013-10-24 15:32
謝謝喔 測試成功 可是 如果我今天EXCEL 有圖片 or 文字 想一併轉換 想請問 有什麼方法呢
還有 如何學習 vba 的 轉換呢
作者:
genes
時間:
2013-10-24 16:19
回復
4#
xperia0603
請附上檔案
作者:
xperia0603
時間:
2013-10-29 01:41
回復
5#
genes
抱歉 最近忙於一些事情 耽擱了 vba的學習
目前卡在
假設 我有這些數值
100 101 102 103 104
200 201 202 203 204
300 301 302 303 304
400 401 402 403 404
500 501 502 503 504
如何利用 vba 把這些數值 變成 長條圖 圓餅圖等 然後 轉換成 power point 上面的pag呢?
[attach]16504[/attach]
作者:
Ling2050
時間:
2015-1-10 15:27
回復
2#
genes
您好,參考您所提供的 VBA,對我受益良多。
想再詢問,對於由Excel VBA所拋轉出的ppt檔案,是否能如同EXCEL一般,再透過VBA可自動存檔或是指定到相關路徑等方法。
歡迎光臨 麻辣家族討論版版 (http://forum.twbts.com/)