【问题标题】:Powerpoint VBA - Distribute columns evenlyPowerpoint VBA - 均匀分布列
【发布时间】:2010-02-24 08:23:04
【问题描述】:

我正在使用 PowerPoint 2000,它没有 2003 和更高版本具有的均匀分布列功能。有谁知道将使用什么 VBA 代码来均匀分布选定的表列?

(我知道如何通过查找表格宽度、将其除以列数并将每列的宽度调整为该划分的宽度来为整个表格执行此操作。但是,我在仅将其应用于选择时遇到了问题. 例如,在一个 7 列的表中右 5 列。)

【问题讨论】:

    标签: vba powerpoint


    【解决方案1】:

    这将为您解决问题。只需确保在运行时选择了列。

    Sub DistributeSelectedColumnsEvenly()
    Dim sel As Selection
    Set sel = ActiveWindow.Selection
    Dim fColumn As Integer
    fColumn = 0
    Dim lColumn As Integer
    Dim columnsWidth As Integer
    
    With sel
        If .Type = ppSelectionShapes Then
            If .ShapeRange.Type = msoTable Then
                Dim tbl As Table
                Set tbl = .ShapeRange.Table
                Dim tblColumnCount As Integer
                tblColumnCount = tbl.Columns.Count
                For colNum = 1 To tblColumnCount
                    If tbl.Cell(1, colNum).Selected Then
                    columnsWidth = columnsWidth + tbl.Cell(1, colNum).Parent.Columns(colNum).Width
                        If fColumn = 0 Then
                            fColumn = colNum
                        End If
                        lColumn = colNum
                    End If
                Next
                Dim columnCount As Integer
                columnCount = (lColumn - fColumn) + 1
                Dim columnWidth As Integer
                columnWidth = columnsWidth / columnCount
                For columnIndex = fColumn To lColumn
                    tbl.Columns(columnIndex).Width = columnWidth
                Next
            End If
        End If
    End With
    End Sub
    

    【讨论】:

      【解决方案2】:

      取您尝试分配的列宽的总和,然后除以列数。

      【讨论】:

        猜你喜欢
        • 2011-04-04
        • 2011-11-30
        • 2011-09-16
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-06-28
        • 2016-03-20
        • 2011-03-02
        相关资源
        最近更新 更多