Private Sub Command1_Click()
Dim pptob As Object
Dim pptsl As Object
Dim ppApp As Object
Dim txobject As Object
Dim ppLayoutBlank As Integer
Dim lngLastSlideAdded As Long
ppLayoutBlank = 12
CommonDialog1.Filter = "文本文档(*.doc) *.doc 所有文件(*.*) *.*"
CommonDialog1.ShowSave
FileName = CommonDialog1.FileName
Set pptob = CreateObject("PowerPoint.Application")
Set ppApp = pptob.Presentations.Add(msoFalse)
Set pptsl = ppApp.Slides.Add(ppApp.Slides.Count + 1, ppLayoutBlank)
Set shpCurrShape = pptsl.Shapes.AddTextbox(msoTextOrientationHorizontal, 100, 100, 500, 500)
With shpCurrShape
With .TextFrame.TextRange
.Text = "'If not now, when? If not us, who?'" _
& vbCrLf & "'There is no time like the present.'" _
& vbCrLf & "'Ask not what your country can do for you, " _
& "ask what you can do for your country.'"
With .ParagraphFormat
.Alignment = ppAlignLeft
.Bullet = msoTrue
End With
With .Font
.Bold = msoTrue
.Name = "Tahoma"
.Size = 24
End With
End With
End With
lngLastSlideAdded = pptsl.SlideID
ppApp.SaveAs FileName
Set ppApp = Nothing
Set pptsl = Nothing
Set pptob = Nothing
End Sub
这是我用vb在ppt里添加文本框的代码
一直有错误
不知道是什么原因
那位大哥能帮小弟看看
Dim pptob As Object
Dim pptsl As Object
Dim ppApp As Object
Dim txobject As Object
Dim ppLayoutBlank As Integer
Dim lngLastSlideAdded As Long
ppLayoutBlank = 12
CommonDialog1.Filter = "文本文档(*.doc) *.doc 所有文件(*.*) *.*"
CommonDialog1.ShowSave
FileName = CommonDialog1.FileName
Set pptob = CreateObject("PowerPoint.Application")
Set ppApp = pptob.Presentations.Add(msoFalse)
Set pptsl = ppApp.Slides.Add(ppApp.Slides.Count + 1, ppLayoutBlank)
Set shpCurrShape = pptsl.Shapes.AddTextbox(msoTextOrientationHorizontal, 100, 100, 500, 500)
With shpCurrShape
With .TextFrame.TextRange
.Text = "'If not now, when? If not us, who?'" _
& vbCrLf & "'There is no time like the present.'" _
& vbCrLf & "'Ask not what your country can do for you, " _
& "ask what you can do for your country.'"
With .ParagraphFormat
.Alignment = ppAlignLeft
.Bullet = msoTrue
End With
With .Font
.Bold = msoTrue
.Name = "Tahoma"
.Size = 24
End With
End With
End With
lngLastSlideAdded = pptsl.SlideID
ppApp.SaveAs FileName
Set ppApp = Nothing
Set pptsl = Nothing
Set pptob = Nothing
End Sub
这是我用vb在ppt里添加文本框的代码
一直有错误
不知道是什么原因
那位大哥能帮小弟看看
Dim PPT As PowerPoint.Presentation
Set PPT = GetObject("c:\1.ppt")
PPT.Application.Visible = msoCTrue
PPT.Slides(1).Shapes.AddLabel msoTextOrientationHorizontal, 100, 100, 100, 100
PPT.Slides(1).Shapes.AddLabel msoTextOrientationVerticalFarEast, 200, 200, 200, 200
End Sub
调试时PPT.Application.Visible = msoCTrue 这一句错误
msoCTrue 为空值
我的代码是直接生成ppt
你的代码是找到ppt并添加文本框
可是我的代码错在哪里了呢?
具体错误我也说不清