- Tham gia
- 13/6/06
- Bài viết
- 7,182
- Được thích
- 24,625
Tôi xin giới thiệu code điều khiển PowerPoint từ Excel (Sưu tầm):
Các bạn nhớ khai báo Microsoft Power Point ... Type Libary trong VBE/Tools/References nhé.
Mã:
Sub Excel_PowerPoint()
Dim ppApp As Object
Set ppApp = CreateObject("Powerpoint.Application")
Dim ppPres As PowerPoint.Presentation
Set ppPres = ppApp.Presentations.Add(msoTrue)
Dim ppSlide1 As PowerPoint.Slide
Set ppSlide1 = ppPres.Slides.Add(1, ppLayoutText)
ppSlide1.Shapes(1).TextFrame.TextRange.Text = "Luan van tot nghiep"
ppSlide1.Shapes(2).TextFrame.TextRange.Text = "Sinh vien" & vbCr & "Nguyen Van A"
Dim ppSlide2 As PowerPoint.Slide
Set ppSlide2 = ppPres.Slides.Add(2, ppLayoutTextAndChart)
ppSlide2.Shapes(1).TextFrame.TextRange.Text = "De tai"
ppSlide2.Shapes(2).TextFrame.TextRange.Text = "Chuyen ma tieng Viet"
Dim cTop As Double
Dim cWidth As Double
Dim cHeight As Double
Dim cLeft As Double
With ppSlide2.Shapes(3)
cTop = .Top
cWidth = .Width
cHeight = .Height
cLeft = .Left
.Delete
End With
ppSlide2.Shapes.AddOLEObject cLeft, cTop, cWidth, cHeight, "MSGraph.Chart"
With ppPres.SlideShowSettings
.AdvanceMode = ppSlideShowUseSlideTimings
.Run
End With
'ppPres.SaveAs App.Path & "\test.ppt"
End Sub
Các bạn nhớ khai báo Microsoft Power Point ... Type Libary trong VBE/Tools/References nhé.