* 使用 VFP 自动执行 PowerPoint 的演示
* Start PowerPoint
PptApp = Createobject("Powerpoint.Application")
* Add a presentation
PptPres = PptApp.Presentations.Add(1)
* Add a slide
PptSlide1 = PptPres.Slides.Add(1,2)
* Add some text...
PptSlide1.Shapes(1).TextFrame.TextRange.Text = "我的第一幅画面"
PptSlide1.Shapes(2).TextFrame.TextRange.Text = "Powerpoint 自动化是很容易的" + Chr(13) + "FoxPro 是非常棒的!"
* Add another slide, with a chart
PptSlide2 = PptPres.Slides.Add(2,5)
* Add some text
PptSlide2.Shapes(1).TextFrame.TextRange.Text = "第二幅画面的标题"
PptSlide2.Shapes(2).TextFrame.TextRange.Text = "你可以创建你的 PPT 幻灯图表!"
* Add a chart where the old one is...
With PptSlide2.Shapes(3)
cTop = .Top
cWidth = .Width
cHeight = .Height
cLeft = .Left
.Delete
Endwith
PptSlide2.Shapes.AddOLEObject(cLeft, cTop, cWidth, cHeight, "MSGraph.Chart")
* Add another slide, with an Organization chart
PptSlide3 = PptPres.Slides.Add(3,7)
* Add some text
PptSlide3.Shapes(1).TextFrame.TextRange.Text = "剩下的只有你的想象力的限制!"
* Add an Org chart where old one is...
With PptSlide3.Shapes(2)
cTop = .Top
cWidth = .Width
cHeight = .Height
cLeft = .Left
.Delete
Endwith
* PptSlide3.Shapes.AddOLEObject(cLeft, cTop, cWidth, cHeight, "OrgPlusWOPX.4")
* Uncomment the above line if you have the correct file.
* Setup slide show properties...
With PptPres.Slides.Range.SlideShowTransition
.EntryEffect = 513
.AdvanceOnTime = 1
.AdvanceTime = 5
Endwith
* Prepare and run slide-show!
With PptPres.SlideShowSettings
.ShowType = 3
.LoopUntilStopped = 1
.RangeType = 1
.AdvanceMode = 2
.Run
Endwith
* Sleep so user can watch the show...
Wait Window "正在等待幻灯演示的完成..." Timeout 16
* SaveAs PPT to JPG
#DEFINE ppSaveAsJPG 17
pptApp.ActivePresentation.SaveAs("D:\MyPPT", ppSaveAsJPG)
* Stop the slide show
PptPres.SlideShowWindow.View.Exit
* Clean up
PptApp.Quit
Release PptSlide3
Release PptSlide2
Release PptSlide1
Release PptPres
Release PptApp