如何解决VBA:基于Excel表更新形状属性
我有一个Excel表,其中包含从PowerPoint文件中提取的A:L列中的所有属性。我正在尝试根据表格中列出的属性更新PowerPoint中的形状(即填充颜色显示为红色,然后在Excel中将其更改为蓝色,然后单击执行并在PowerPoint中进行更新)。知道为什么这失败了吗?
我有以下代码,但在以下行中失败:
For Each oSl In oSlides
Error: Runtime Error '424' Object required
Sub test()
Dim PPT As PowerPoint.Application
Dim pres As PowerPoint.Presentation
Dim newslide As PowerPoint.Slide
Dim slideCtr As Integer
Dim tb As PowerPoint.Shape
Dim i As Long: i = 1
Dim oShAttributes As Range
Dim oSlides As Slides
Dim oSl As Slide
Dim oSh As Shape
Set oShAttributes = Range("A1:L5")
Set PPT = CreateObject("PowerPoint.Application")
PPT.Visible = True
Set oSlides = PPT.Presentations.Open( _
"C:\Users\xxxx\Documents\vbatest.pptx")
slideCtr = 1
For Each oSl In oSlides
For Each oSh In oSl.Shapes
oSh.Name = oShAttributes(i,2)
oSh.Fill.ForeColor.RGB = oShAttributes(i,3)
oSh.TextFrame.TextRange.Font.Name = oShAttributes(i,4)
oSh.TextFrame.TextRange.Font.Size = oShAttributes(i,5)
oSh.TextFrame.TextRange.Font.Color.RGB = oShAttributes(i,6)
oSh.TextFrame.TextRange.Text = oShAttributes(i,7)
oSh.Left = oShAttributes(i,9)
oSh.Top = oShAttributes(i,10)
oSh.Width = oShAttributes(i,11)
oSh.Height = oShAttributes(i,12)
i = i + 1
Next oSh
Next oSl
End Sub
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。