|
想excel中A列单元格内容转为PPT每页标题
网上找到下面宏
是选定了当前sheet的A列,然后把这一列内容拷贝到ppt中,
每一个单元格值做ppt的一页中的一个标题
但是
Set ptSld = ptPre.Slides.Add(Index:=ptPre.Slides.Count + 1, Layout:=ppLayoutBlank)
到这句就出错了 后面不知道还有没有错
请各位老师指导修改一下
Sub test()
Dim ptApp As Object
Set ptApp = CreateObject("PowerPoint.Application")
Dim ptPre As Object
Set ptPre = ptApp.Presentations.Add
Dim ptSld As Object
Dim ptShape As Object
ptApp.Visible = msoTrue
ActiveSheet.Names.Add Name:="NewWord", RefersTo:="=OFFSET($A$1,0,0,COUNTA($A:$A))"
Set R = ActiveSheet.Names("NewWord").RefersToRange
dd = R.Count - 1
For rr = 2 To dd + 1
Set ptSld = ptPre.Slides.Add(Index:=ptPre.Slides.Count + 1, Layout:=ppLayoutBlank)
Set ptShape = ptSld.Shapes.AddTextbox(Orientation:=msoTextOrientationHorizontal, _
Left:=10, Top:=17, Width:=700, Height:=50)
With ptShape.TextFrame
.TextRange.Text = R(rr)
.TextRange.Font.Name = "楷体_GB2312"
.TextRange.Font.Size = 30
.TextRange.Font.Color.RGB = RGB(Red:=0, Green:=0, Blue:=255)
.TextRange.Font.Bold = True
End With
Set ptShape = ptSld.Shapes.AddTextbox(Orientation:=msoTextOrientationHorizontal, _
Left:=10, Top:=80, Width:=700, Height:=450)
With ptShape.TextFrame
.TextRange.Text = "This is for test!"
.TextRange.Font.Name = "楷体_GB2312"
.TextRange.Font.Size = 25
End With
ptSld.Shapes(2).TextFrame.TextRange.Characters.Font.Color = vbBlack
Next rr
End Sub
|
|