|
如题,写了段代码,目的是新建一个ppt文档添加内容后保存到指定位置:
Function CreatePowerPoint(sFilePath,sFileContent) 'As PowerPoint Application
Dim PowerPointApp,PowerPointPresentation,PowerPointSlide
Set PowerPointApp = CreateObject("PowerPoint.Application") 'Create a new PowerPoint Object
PowerPointApp.Visible = True 'Make it visible
Set PowerPointPresentation = PowerPointApp.Presentations.Add'Add the property of PowerPoint
PowerPointPresentation.SaveAs(sFilePath)
Set PowerPointSlide =PowerPointPresentation.Slides.Add(1,PowerPointPresentation.Slides.Count+1) '.Slides.Add(CurrentSlideNumber,TotalSlideNumber)
PowerPointPresentation.Slides(1).Shapes.Item(1).TextFrame.TextRange.Select
Set PowerPointPresentation.Slides(1).Shapes.Item(1).TextFrame.TextRange.text = sFileContent
Set PowerPoint = Nothing
Set PowerPointPresentation = Nothing
Set PowerPointSlide = Nothing
End Function
Call CreatePowerPoint("c:\ppt.ppt","H")
可问题是运行到这句:Set PowerPointPresentation.Slides(1).Shapes.Item(1).TextFrame.TextRange.text = sFileContent
总说找不到TextFrame.TextRange.text对象
搞不懂是为什么了
知道的麻烦指点下,先谢谢了 |
|