kevinchi
小學生
離線
文章: 3
|
相信大家都想要自動化的文書作業,只要使用巨集去撈資料庫的資料來畫Charts,用巨集畫Charts相信大家都會,但如何把畫出來的Charts貼到Power Point上呢 小弟寫了兩個版本,先公佈精簡版如何寫 只要在活頁簿中產生一個Charts就可以執行以下的動作,或是你可以用巨集產生一個Charts,接著再Run以下的程式。 在執行這個之前,請到工具->設定引用項目,將Microsoft power Point x.0 Object Library勾選起來
Sub Copy_charts_To_PPT()
Dim myPpApp As PowerPoint.Application Dim myPpPrs As PowerPoint.Presentation Set myPpApp = CreateObject("powerpoint.application") myPpApp.Visible = msoTrue Set myPpPrs = myPpApp.Presentations.Add Worksheets(1).ChartObjects(1).Copy For i = 1 To 5 With myPpPrs .Slides.Add(Index:=i, Layout:=ppLayoutBlank).Shapes.Paste Application.Wait Now() + TimeValue("00:00:01") '.Close End With Next Filename = "123" FilePath = "C:\" & Filename & ".ppt" myPpPrs.SaveAs Filename:=FilePath myPpPrs.Close Set myPpPrs = Nothing Set myPpApp = Nothing End Sub
|