欢迎来到论文网! 识人者智,自知者明,通过生日认识自己! 生日公历:
网站地图 | Tags标签 | RSS
论文网 论文网8200余万篇毕业论文、各种论文格式和论文范文以及9千多种期刊杂志的论文征稿及论文投稿信息,是论文写作、论文投稿和论文发表的论文参考网站,也是科研人员论文检测和发表论文的理想平台。lunwenf@yeah.net。
您当前的位置:首页 > 科技论文 > 计算机论文

例谈VB批改操作题的实现

时间:2010-11-30  作者:秩名
score3= score3 + 0.9
 

End If

myDoc3.Close

SetmyDoc3 = Nothing

Setappwd = Nothing

Print "三、段落格式(8分):", score3; "分"

四、页面设置(7分)

⑴页面纸张大小设为A5(21厘米宽×14.8厘米高),纸张方向为横向,页边距上下均为2.5厘米、左右均为2.0厘米,并在左边预留0.8厘米的装订线位置。

Dim myDoc4 As Object

Set appwd = CreateObject("Word.Application")

Set myDoc4 = appwd.Documents.Open(App.Path & "\9028\段落B.doc")

If myDoc4.PageSetup.TopMargin= 70.9 Then

score4 = score4 + 0.2 '页边距上 2.5cm=70.9磅

End If

If myDoc4.PageSetup.BottomMargin = 70.9 Then

score4 = score4 + 0.2 '页边距下 2.5cm=70.9磅

End If

If myDoc4.PageSetup.LeftMargin = 56.7 Then

score4 = score4 + 0.2 '左页边距 2.0cm=56.7磅

End If

If myDoc4.PageSetup.RightMargin = 56.7 Then

score4 = score4 + 0.2 '右页边距 2.0cm=56.7磅

End If

IfmyDoc4.PageSetup.Gutter = 22.7 Then

score4 = score4 + 0.4 '左边预留0.8厘米的装订线位,0.8cm=22.7磅

End If

IfmyDoc4.PageSetup.PageWidth = 595.35 Then

score4= score4 + 0.2 'A5(宽21cm=595.35磅)

End If

If myDoc4.PageSetup.PageHeight = 419.6 Then

score4 = score4 + 0.2 'A5(高14.8cm=419.6磅)

End If

⑵标题文字为幼圆、三号字、加粗,加着重号,居中。

……

IfmyDoc4.Paragraphs(1).Range.Text.Font.Bold = wdToggle Then

score4 = score4 + 0.4 '加粗

EndIf

⑶将考试文件夹中的Tpe.TXT文件内容插入到本文档中,并调整各段落位置,使文档的段落编号由a到e排列;

Dim ye41 AsString'记录段落1至6内容

……

Dim ye46 AsString

IfmyDoc4.Paragraphs.Count > 3 Then '原文档有3个段落,若插入了新文档,则往下判断

ye41 = myDoc4.Paragraphs(1).Range.Text

……

ye46 = myDoc4.Paragraphs(6).Range.Text

IfLeft(ye41, 10) = "苹果电脑专卖店的特色" Then

score4 = score4 + 0.3 '文字内容

End If

'判断各段落首行第1个字母是否依次为a、b、c、d、e,从而确定段落排序正确性

IfLeft(ye42, 1) = "a" Then

score4= score4 + 0.3

End If

……

If Left(ye46, 1) = "e" Then

score4 = score4 +0.3

End If

End If

⑷在页面底端居中位置插入页码,起始页码为e,设置页眉,居中,内容为:苹果电脑。

Dim ye444 As String

If myDoc4.Sections(1).Headers(1).PageNumbers.StartingNumber = 5 Then

score4 = score4 + 0.6 '页码

End If

If myDoc4.Sections(1).Footers(1).PageNumberAlignment= wdAlignPageNumberCenter Then

score4 = score4 + 0.5 '居中

EndIf

ye444= myDoc4.Sections(1).Headers(wdHeaderFooterPrimary).Range.Text

If Left(ye444, 4) = "苹果电脑"Then

score4 = score4 + 0.5 '页眉内容

End If

myDoc4.Close

Set myDoc4 =Nothing

Set MyWord =Nothing

Print"四、页面设置(7分):", score4; "分"

五、表格制作(5分)

(1)制作如下表所示的表格,并填入相应文字;

(2)表格中的第1行的行高为最小值32磅;

(3)表格采用套用格式“古典型1”,全部单元格对齐方式设置为中部居中。

省份 小学生数 中学生数 大学生数
广东      
广西      
海南      

Dim MyTable As Object'定义表格对象变量

Dim myDoc5 As Object

Dim biao511 AsString '第5题第2个表格中的第(1,1)个单元格

……

Dim biao521 AsString '第5题第2个表格中的第(2,1)个单元格

……

Dim biao529 As String '第5题第2个表格中的第(2,9)个单元格

Dim biao541 AsString '第5题第2个表格中的第(4,1)个单元格

Set appwd =CreateObject("Word.Application")

Set myDoc5= appwd.Documents.Open(App.Path & "\9028\表格制作.doc")

'item从1开始计算,因为第一个表格是题目要求且锁住了,只能看不能修改。

SetMyTable = myDoc5.Tables.Item(2)

biao511= MyTable.Cell(1, 1).Range.Text ' 获取第二个表格中第1行第1列单元格内容

……

biao541 = MyTable.Cell(4, 1).Range.Text

IfLeft(biao511, 2) = "省份" Then

score5 = score5 + 0.2 '表格中的文字内容填对的,每个单元格给0.2分,以下共7个

End If

……

If Left(biao541, 2) = "海南" Then

score5 = score5 + 0.2

End If

'(逐一写出每一单元格的对齐方式,共16个)

IfmyDoc5.Tables.Count = 2 Then '第1个表格为题目,若表格数为2,评第2个表格

If MyTable.Cell(1, 1).VerticalAlignment = wdCellAlignVerticalCenter AndMyTable.Cell(1, 1).VerticalAlignment = wdAlignParagraphCenter Then

score5 = score5 + 0.1'对齐方式

EndIf

……

If MyTable.Cell(4, 4).VerticalAlignment = wdCellAlignVerticalCenter AndMyTable.Cell(4, 4).VerticalAlignment = wdAlignParagraphCenter Then

score5 = score5 + 0.1

End If

End If

If MyTable.Cell(1, 1).Height = 32 Then

score5 = score5 + 0.5 '单元格(1,1)最小值32磅,即1.13厘米

End If

If MyTable.Rows(1).HeightRule = wdRowHeightAtLeast Then

score5 = score5 + 0.5'最小值

End If

IfSelection.Tables(1).Style = "古典型 1"Then

score5 = score5 + 1'套用格式对得分

End If

myDoc5.Close

Set myDoc5 =Nothing

Set appwd =Nothing

Print "五、表格制作(5分):", score5; "分"

六、表格修改(5分)

考生姓名 语文 数学 英语 综合 物理 化学 生物 总分
张进 78 85 86 83 332

(1)将下表第1行第1列与第2行第1列 的文字内容对调

(2)将下表中第1行第5列拆分单元格成1行4列,填入如上表一样的文字,并在第2行最后一列用求和公式计算总分

(3)将下表中全部单元格对齐方式设置为中部居中 (修改后的表格如上表所示)

张进 语文 数学 英语 综合 总分
考生姓名 78 85 86 83  

Dim myDoc6 As Object

Dim biao611 As String '第6题第2个表格中的第(1,1)个单元格

……

Dim biao629 As String '第6题第2个表格中的第(2,9)个单元格

Set appwd = CreateObject("Word.Application")

Set myDoc6 = appwd.Documents.Open(App.Path & "\9028\表格修改.doc")

'item从1开始计算,第1个表格为题目,评判第2个表格

Set MyTable = myDoc6.Tables.Item(2)

'获取表格中的内容

On Error ResumeNext

biao611 = MyTable.Cell(1, 1).Range.Text

……

biao629 = MyTable.Cell(2, 9).Range.Text

IfLeft(biao612, 2) = "语文" And Left(biao613, 2) = "数学" And Left(biao614, 2) = "英语" And Left(biao615, 2) = "综合" Then ‘在不更改原来题目中的单元格摘要求给分

IfLeft(biao611, 4) = "考生姓名" Then '文字内容每空0.3分,5个空共1.5分

score6 = score6 + 0.3

EndIf

……

If Left(biao621, 2) ="张进" Then

score6 = score6 + 0.3

End If

End If

IfMyTable.Cell(2, 6). Formula ="=SUM(LEFT)" Or Left(biao626, 3) = "332"Then

score6 = score6 + 2 'Word公式

EndIf

(逐一写出每一单元格的对齐方式,共15个)

' wdAlignParagraphJustify两端对齐,'wdAlignParagraphCenter水平居中

IfMyTable.Cell(1, 1).VerticalAlignment = wdCellAlignVerticalCenter AndMyTable.Cell(1, 1).VerticalAlignment = wdAlignParagraphCenter Then

score6 = score6 + 0.1  '垂直居中

End If

……

If MyTable.Cell(2,6).VerticalAlignment = wdCellAlignVerticalCenter And MyTable.Cell(2,6).VerticalAlignment = wdAlignParagraphCenter Then

score6 = score6 + 0.1

End If

myDoc6.Close

Set myDoc6 =Nothing

Set appwd =Nothing

Print"六、表格修改(5分):", score6; "分"

七、格式设置(4分)

(说明:首先必须在VB工程中引用“MicrosoftExcel 11.0 Object Library”)

打开[XLS-2.XLS]文件,在工作表Sheet1中完成以下操作。

⑴将A2:B2区域数据移动到以C2为左上角的区域。

⑵将A3:D3中的所有单元格格式设置为加粗、居中。

Workbooks.Open FileName:=(App.Path &"\9028\xls-2.xls")

Sheets("Sheet1").Activate

Range("C2").Select

If ActiveCell.FormulaR1C1 = "班级:" Then score7 = score7 + 1

Range("D2").Select

If ActiveCell.FormulaR1C1 = "01级管理"Then score7 = score7 + 1

Range("A3:D3").Select

If Selection.Font.Bold = True Then score7 = score7 + 1

If Selection.HorizontalAlignment = xlCenter Then score7 = score7 +1

Workbooks.Close

Excel.Application.DisplayAlerts = False '关闭时是否提示保存(true 保存;false 不保存)

查看相关论文专题
加入收藏  打印本文
上一篇论文:基于SAP平台的企业门户分级授权的实现
下一篇论文:多站点水情信息编码并发传输模式
科技论文分类
科技小论文 数学建模论文
数学论文 节能减排论文
数学小论文 低碳生活论文
物理论文 建筑工程论文
网站设计论文 农业论文
图书情报 环境保护论文
计算机论文 化学论文
机电一体化论文 生物论文
网络安全论文 机械论文
水利论文 地质论文
交通论文
相关计算机论文
最新计算机论文
读者推荐的计算机论文