Vba 我再次收到混合单元格宽度错误 子演示() Application.ScreenUpdating=False 变暗,变长 调光范围 使用ActiveDocument.Tables(1) 对于r=2到.Rows.Count 带.Rows(r) 如果.Cells.Count4,则.Cells(3).删除 以 下一个 ActiveDocument.Tables(1).单元格(1,2).删除 以 Application.ScreenUpdating=True 端接头

Vba 我再次收到混合单元格宽度错误 子演示() Application.ScreenUpdating=False 变暗,变长 调光范围 使用ActiveDocument.Tables(1) 对于r=2到.Rows.Count 带.Rows(r) 如果.Cells.Count4,则.Cells(3).删除 以 下一个 ActiveDocument.Tables(1).单元格(1,2).删除 以 Application.ScreenUpdating=True 端接头,vba,ms-word,Vba,Ms Word,正如我在您的另一个线程中指出的,该过程必须在单元级别完成。因此: Sub Demo() Application.ScreenUpdating = False Dim r as Long Dim C As Range With ActiveDocument.Tables(1) For r = 2 To .Rows.Count With .Rows(r) If .Cells.Count <

正如我在您的另一个线程中指出的,该过程必须在单元级别完成。因此:

Sub Demo()
    Application.ScreenUpdating = False
    Dim r as Long
    Dim C As Range
    With ActiveDocument.Tables(1)
        For r = 2 To .Rows.Count

            With .Rows(r)
                If .Cells.Count < 5 Then .Cells(2).Delete
                If .Cells.Count > 4 Then .Cells(3).Delete

            End WIth
        Next
        ActiveDocument.Tables(1).Cell(1,2).Delete
    End With
    Application.ScreenUpdating = True
End Sub
带.Rows(r)
如果.Cells.Count小于3,则
.单元格(2).宽度=英寸点(4)
.单元格(3).宽度=英寸点(2)
ElseIf.Cells.Count>4则
.单元格(2).宽度=英寸点(4)
.单元格(3).宽度=英寸点(2)
.单元格(4).宽度=英寸点(3)
如果结束
以

您想要实现什么目标?你从哪里得到的错误?如果你想与macropod进一步互动,macropod为你回答了一个问题,你最好对这个答案写一条评论。或者,如果你写了一个新问题,你需要在问题中包含所有相关信息,或者如果仍然相关的话,发布一个到前一个问题的链接。目前,这个新问题还不清楚,因为它没有包含所有必要的信息。另外,请注意您使用的标记:
word
不是有关Microsoft word的问题的有效标记-它在您键入该标记时显示的文本中说明了这一点。错误的代码..With.Rows(r)If.Cells.Count<3 Then ActiveDocument.Tables(1)。Columns(2)。Width=InchesToPoints(4)ActiveDocument.Tables(1)。Columns(3)。Width=InchesToPoints(2)如果.Cells.Count>4,则结束ActiveDocument.Tables(1)。列(2)。宽度=InchesToPoints(4)ActiveDocument.Tables(1)。列(3)。宽度=InchesToPoints(2)ActiveDocument.Tables(1)。列(4)。宽度=InchesToPoints(3)如果结束,则结束我希望宏调整列宽ActiveDocument.Tables(1)。列(2)。宽度=InchesToPoints(4)是的,过了一会儿,我注意到我在操作列,而不是单元格:ActiveDocument.Tables(1).columns(3).Width
        With .Rows(r)
            If .Cells.Count < 3 Then
                .Cells(2).Width = InchesToPoints(4)
                .Cells(3).Width = InchesToPoints(2)
            ElseIf .Cells.Count > 4 Then
                .Cells(2).Width = InchesToPoints(4)
                .Cells(3).Width = InchesToPoints(2)
                .Cells(4).Width = InchesToPoints(3)
            End If
        End With