下载首页下载分类最近更新排 行 榜国产软件国外软件汉化补丁本站论坛BT下载页
  • 设为首页
  • 收藏本站
  • 联系我们
您的位置:首页办公软件Word → Word中利用VBA编程制作考试用作文稿纸
Word中利用VBA编程制作考试用作文稿纸
出处:互联网络 作者:佚名 日期:2007-4-18 21:32:43 人气: [ ]
  

 

  5.插入一个窗体UserForm1,在其中插入4个标签,4个文本框,一个按钮。分别设置它们的相关属性,其中,“所需行数”文本框的“text”属性值设为25,“所需列数”文本框的“text”属性值设为20,“行间距”文本框的“text”属性值设为0.5,“首尾空行高度”文本框的“text”属性值设为0.4,如图3所示。

  6.双击命令按钮CommandButton1,录入以下代码:

Private Sub CommandButton1_Click()
    Dim n As Integer    '定义一个变量为整数型
    n = 1
    ActiveDocument.Tables.Add Range:=Selection.Range, NumRows:=Val(TextBox1.Text) * 2 + 1, NumColumns _
    :=Val(TextBox2.Text), DefaultTableBehavior:=wdWord9TableBehavior, AutoFitBehavior:=wdAutoFitFixed
    Selection.EndKey Unit:=wdRow, Extend:=True
    Selection.Cells.Borders(wdBorderVertical).LineStyle = wdLineStyleNone
    Selection.Tables(1).Rows.HeightRule = wdRowHeightExactly
    '设定表格行高为固定值
    Selection.Tables(1).Rows.Height = CentimetersToPoints(Val(TextBox3.Text))
    '设置表格行高为设置值,作为行间距
    Selection.Tables(1).Rows(1).Height = CentimetersToPoints(Val(TextBox4.Text))
    '设置第一行行高为设置值
    Do While n < Val(TextBox1.Text) + 1
        Selection.EndKey Unit:=wdLine
        Selection.MoveRight Unit:=wdCharacter, Count:=2
        '将插入点移至下一行
        Selection.Tables(1).Rows(2 * n).Height = Selection.Tables(1).Columns(1).PreferredWidth
        '设行高等于列宽
        Selection.EndKey Unit:=wdRow, Extend:=True
        Selection.EndKey Unit:=wdLine
        Selection.MoveRight Unit:=wdCharacter, Count:=2
        '将插入点移至下一行
        Selection.EndKey Unit:=wdRow, Extend:=True
        Selection.Cells.Borders(wdBorderVertical).LineStyle = wdLineStyleNone
        '去除此行的内部框线,只余边框
        n = n + 1
    Loop
    Selection.Tables(1).Rows(Val(TextBox1.Text) * 2 + 1).Height = CentimetersToPoints(Val(TextBox4.Text))
    '设置末行高为设置值
    Selection.EndKey Unit:=wdRow, Extend:=True
    Selection.Cells.Borders(wdBorderVertical).LineStyle = wdLineStyleNone
    Selection.Tables(1).Rows.Alignment = wdAlignRowCenter
    '表格居中
    With Selection.Tables(1)
        .Borders(wdBorderLeft).LineWidth = wdLineWidth150pt
        .Borders(wdBorderRight).LineWidth = wdLineWidth150pt
        .Borders(wdBorderTop).LineWidth = wdLineWidth150pt
        .Borders(wdBorderBottom).LineWidth = wdLineWidth150pt
        '设定表格边框为粗线
    End With
    Selection.EndKey Unit:=wdLine
    Unload Me  
End Sub

评论人 评论内容摘要(共 0 条,查看完整内容) 得分 0 发表时间
关于本站 | 广告服务 | 版权声明 | 联系我们 | | 联系我 | 交流群:1361692 7710545
本站部分带宽由:华夏名网武汉IDC数据中心 赞助[排名不分先后] Powered By 零度软件园
本站软件均来源于网络,仅供学习所用。若侵犯了你的权益,请立即通知我们,我们将第一时间删除!