从两个组合框转换值以建立表格

时间:2019-01-04 22:36:52

标签: vba combobox ms-word integer

首先,谢谢您……这里的每个人都令人难以置信

所以我想做的是使用两个组合框(cb_RNNumberPayments和cb_CountCohorts)将表插入书签“ FeeTable”中的文档中。另外,我正在尝试确保正确设置表格的格式(但这可能是以后的工作)。现在,由于该表具有标题(因此需要使其具有oRow + 1)并具有两个附加列(oCol +2),并且根据我已阅读的内容,combox不能读取为整数,因此我遇到了很多问题。如果只设置oRow = 4和oCol = 4,我可以使它工作,但是由于每次列号和行号每次都不同,因此我想将其写为基于组合框...使感官吗?我还希望在列标题中插入特定文本(Col1护理程序类,Col2第一学期,Col3第二学期,Col4-6取决于该列是否基于组合框cb_RNNumberPayments而存在,最后一个col应该是Total Fee < / p>

Sub FeeTable()
    Dim oRng As Word.Range, oTbl As Word.Table
    Dim RNPayment As Integer
    Dim nCohort As Integer
    Dim oRow As Integer
    Dim oCol As Integer

    Set oRng = ActiveDocument.Range.Bookmarks("FeeTable").Range
    Set oCol = cb_RNNumberPayments.Value + 2
    Set oRow = cb_CountCohorts.Value + 1
    Set oTbl = ActiveDocument.Tables.Add(Range:=oRng, NumRows:=oRow, _
                                         NumColumns:=oCol)
    ActiveDocument.Bookmarks.Add "FeeTable", oTbl.Range
    oTbl.Rows.SetLeftIndent LeftIndent:=InchesToPoints(0.3), _
                            RulerStyle:=wdAdjustSameWidth
    With oTbl
        .Borders.InsideLineStyle = wdLineStyleSingle
        .Borders.InsideLineWidth = wdLineWidth025pt
        .Borders.InsideColor = wdColorBlack

        .Borders.OutsideLineStyle = wdLineStyleSingle
        .Borders.OutsideLineWidth = wdLineWidth025pt
        .Borders.OutsideColor = wdColorBlack
    End With

    On Error Resume Next
lbl_Exit:
    Exit Sub
End Sub

0 个答案:

没有答案