vba - Powerpoint Macros: Column(unknown member) error at Columns.Width Formatting code
问题描述
I'm new to coding directly in the Powerpoint Macros interface, while learning formatting I hit a roadblock.
Slide 10 of Presentation has a 5 by 7 table. I would like to adjust the width of column 3.
The code I use is:
Sub FormatTables()
Dim s As Slide
Dim oSh As Shape
Dim oTbl As Table
Dim lRow As Long
Dim lCol As Long
Dim ThisRow As Integer
Set s = ActivePresentation.Slides(10)
s.Select
For Each oSh In s.Shapes
If oSh.HasTable Then
Set oTbl = oSh.Table
oTbl.Columns(1).Width = 72 * 0.5
oTbl.Columns(2).Width = 72 * 0.5
oTbl.Columns(3).Width = 72 * 0.5
For lRow = 1 To oTbl.Rows.Count
For lCol = 1 To oTbl.Columns.Count
With oTbl.Cell(lRow, lCol).Shape.TextFrame.TextRange
.Font.Name = "Georgia"
.Font.Size = 8
End With
Next
Next
End If
Next
The error I get is: "Columns (unknown member): Integer out of range. 3 is not the valid range of 1 to 2.
Also, the width of columns 1 and 2 are adjusting successfully, but the macro hits the error at the line of code of Column 3.
Is there anything I missed?
解决方案
推荐阅读
- java - USACO 2018 年 12 月铜奖的错误输出
- c - 当 i 已经用 0 和 if 条件以及为什么初始化时,它的值是多少?
- python - 如何从每个一级索引的最大二级索引的单元格中选择值?
- python - OpenCV 图像处理后 QLabel 不更新图像
- android - 如何在捕获图像上添加时间戳?
- python - Python:未定义最小值
- amazon-web-services - 没有 AWS 凭证的 Terraform 运行计划
- python - 如何有条件地将一个列表中的元组附加到另一个元组列表?
- c# - EF Core One to Many adding new object
- c# - 在 Any at = IsAvailable = !b.BorrowHistories.Any(h => h.ReturnDate == null) 下获得一条红线