谁能帮我解释下这段AS代码:急onClipEvent (load){function speed(num){speedX

1个回答

  • 这是 VB写的 调用Word 填充数据的.

    On Error Resume Next

    Dim ex As Application '声明

    Set ex = CreateObject("word.application") '创建Word对象

    ex.Visible = True '让Word可见

    Set woreddoc = ex.Documents.Add '添加一个新文档

    ex.Caption = "数据库原理概论试卷" '文档标题名

    ex.Application.Selection.Range.ParagraphFormat.Alignment = wdAlignParagraphCenter '字体居中

    ex.Application.Selection.Font.Size = 14

    ex.Application.Selection.Font.Spacing = 1

    ex.Application.Selection.Font.Bold = 20 '上面设置字体字号的

    ex.Application.Selection.Range.Text = Text.Item(1).Text '从text的项目1获取数据 text 应该是个 combo 或listbox

    ex.Application.Selection.EndKey '移到结尾

    ex.Application.Selection.Range.InsertAfter (Text2.Item(1).Text) + Chr(13) '再填充 加个回车

    ex.Application.Selection.Range.InsertParagraphAfter

    ex.Application.Selection.EndKey

    ex.Application.Selection.MoveDown

    ex.Application.Selection.EndKey

    ex.Application.Selection.Range.InsertParagraphAfter

    ex.Application.Selection.MoveDown

    ex.Application.Selection.MoveDown '下跳

    ex.Application.Selection.Paragraphs.Last.Range.Font.Size = 12

    ex.Application.Selection.Paragraphs.Last.Range.Font.Bold = 0 '再设置字体 字号

    k = ex.Application.Selection.Tables.Add(ex.Application.Selection.Range,2,8,0,0) '这里画了个两行 8列的 表

    ex.Application.Selection.Tables.Item(1).Columns.Item(1).Cells.Item(1).Range.InsertAfter ("题型") '1行1列 填充

    ex.Application.Selection.Tables.Item(1).Columns.Item(1).Cells.Item(2).Range.InsertAfter ("分数") '1行2列填充

    ex.Application.Selection.MoveDown

    ex.Application.Selection.Tables.Item(1).Columns.Item(2).Cells.Item(1).Range.InsertAfter ("一")

    ex.Application.Selection.Tables.Item(1).Columns.Item(3).Cells.Item(1).Range.InsertAfter ("二")

    ex.Application.Selection.Tables.Item(1).Columns.Item(4).Cells.Item(1).Range.InsertAfter ("三")

    ex.Application.Selection.Tables.Item(1).Columns.Item(5).Cells.Item(1).Range.InsertAfter ("四")

    ex.Application.Selection.Tables.Item(1).Columns.Item(6).Cells.Item(1).Range.InsertAfter ("五")

    ex.Application.Selection.Tables.Item(1).Columns.Item(7).Cells.Item(1).Range.InsertAfter ("六")

    ex.Application.Selection.Tables.Item(1).Columns.Item(8).Cells.Item(1).Range.InsertAfter ("总分") '这里添完

    ex.Application.Selection.MoveDown

    ex.Application.Selection.MoveDown '下条

    ex.Application.Selection.Range.InsertParagraphAfter

    ex.Application.Selection.MoveDown

    ex.Application.Selection.Range.ParagraphFormat.Alignment = wdAlignParagraphLeft

    ex.Application.Selection.Paragraphs.Last.Range.Font.Size = 10

    ex.Application.Selection.Paragraphs.Last.Range.Font.Bold = 10 '设置字体字号

    ex.Application.Selection.Range.InsertParagraphAfter

    ex.Application.Selection.Range.InsertAfter ("填空(20分)") '再填充

    ex.Application.Selection.MoveDown

    ex.Application.Selection.Range.InsertParagraphAfte