| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 517 人关注过本帖
标题:[求助]做了一半,还差一半
只看楼主 加入收藏
likedan
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2006-9-27
收藏
 问题点数:0 回复次数:7 
[求助]做了一半,还差一半

我用VBA做了一个评分软件,要评6分的,但我只评了3分,请会VBA的大大看看我那里错了

网络安全大家谈
网络安全是一个关系国家安全和主权、社会的稳定、民族文化的继承和发扬的重要问题。其重要性,正随着全球信息化步伐的加快而变到越来越重要。“家门就是国门”,安全问题刻不容缓。网络安全是一门涉及计算机科学、网络技术、通信技术、密码技术、信息安全技术、应用数学、数论、信息论等多种学科的综合性学科。
网络安全是指网络系统的硬件、软件及其系统中的数据受到保护,不受偶然的或者恶意的原因而遭到破坏、更改、泄露,系统连续可靠正常地运行,网络服务不中断。
对安全保密部门来说,他们希望对非法的、有害的或涉及国家机密的信息进行过滤和防堵,避免机要信息泄露,避免对社会产生危害,对国家造成巨大损失。
从社会教育和意识形态角度来讲,网络上不健康的内容,会对社会的稳定和人类的发展造成阻碍,必须对其进行控制。

要求:
打开Word文档(文件名为:exam_word.doc),然后进行如下操作。
(1)给文章加标题:“网络安全大家谈”,要求:居中,设置标题字体:宋体、粗体、二号、红色、字符缩放200%;
(2)将正文的第一段首字下沉2行,首字字体为楷体、斜体、蓝色;
(3)将正文中所有“安全”设置为黑体、加粗、加单下划线;
(4)将正文的第二段分成等宽的三栏,栏间加分隔线;
(5)设置页眉:“计算机世界”,五号,楷体,粗体,居中;
(6)将文章标题行加上1.5磅带阴影的红色边框、30%的底纹,颜色:黄色;
将编辑好的文件存放于D盘Ks_Word文件夹中。

我的代码:
Sub Auto_pj()
On Error GoTo err
Dim doc1 As Document '定义一个document对象
Set doc1 = CreateObject("word.document") '创建一个document对象
Set doc1 = Word.Documents.Open(FileName:="d:\ks_word\exam_word.doc", ReadOnly:=True) '以只读方式打开一个文档,返回一个document对象
MsgBox ActiveDocument.Name, , "当前活动文档的文件名称是:"
score = 0 '变量score用于记录考生得分
'检查规定目录下是否有所要求的文件
'ChangeFileOpenDirectory "D:\ks_word\"
doc1.Activate
'检查文章标题是否正确
Selection.HomeKey unit:=wdLine
Selection.MoveRight unit:=wdCharacter, Count:=7, Extend:=wdExtend
If Selection.Text = "网络安全大家谈" And Selection.ParagraphFormat.Alignment = _
wdAlignParagraphCenter And Selection.Font.Scaling = 200 Then
score = score + 1 '若正确,则加分
End If
'检查第一段首字格式
Selection.MoveRight unit:=wdCharacter, Count:=2
Selection.MoveRight unit:=wdCharacter, Count:=1, Extend:=wdExtend
If Selection.Paragraphs(1).DropCap.LinesToDrop = 2 Then
If Selection.Font.Italic = True And Selection.Font.Color = wdColorBlue And _
Selection.Font.Name = "楷体_GB2312" Then
score = score + 1
End If
End If
' 查找每一个“安全”,是否都已变为要求的格式,文档中共有7个“安全”
With Selection.Find
.Text = "安全"
.Forward = True
.Wrap = wdFindContinue
End With
j = 0
For i = 1 To 7
If Selection.Find.Execute = True Then
If Selection.Font.Name = "黑体" And Selection.Font.Underline = wdUnderlineSingle Then
j = j + 1
End If
End If
Next i
If j = 7 Then
score = score + 1
End If
'检查文章第二段是否已分为3栏,是否有分隔线
Selection.HomeKey unit:=wdStory
Selection.MoveDown unit:=wdParagraph, Count:=2
Selection.MoveDown unit:=wdParagraph, Count:=1, Extend:=wdExtend
Selection.MoveLeft unit:=wdCharacter, Count:=1, Extend:=wdExtend
ActiveDocument.Range(Start:=Selection.End, End:=Selection.End).InsertBreak Type:= _
wdSectionBreakContinuous
If Selection.PageSetup.TextColumns.Count = 3 And Selection.PageSetup.TextColumns.LineBetween _
<> 0 Then
score = score + 1
End If
'检查页眉是否设置正确
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
Application.WindowState = 1
Selection.EndKey unit:=wdLine, Extend:=wdExtend
Selection.MoveLeft unit:=wdCharacter, Count:=1, Extend:=wdExtend
If Selection.Text = "计算机世界" And Selection.ParagraphFormat.Alignment = _
wdAlignParagraphCenter And Selection.Font.Bold = True And Selection.Font.Name = "楷体GB_2312" Then
score = score + 1
End If
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
'检查标题行的边框设置是否正确
Selection.HomeKey unit:=wdStory
Selection.EndKey unit:=wdLine, Extend:=wdExtend
Selection.MoveLeft unit:=wdCharacter, Count:=1, Extend:=wdExtend
If Selection.Font.Shading.Texture = wdTexture30Percent And _
Selection.Font.Shading.ForegroundPatternColor = wdColorYellow And _
Selection.Font.Shading.BackgroundPatternColor = wdColorAutomatic And _
Selection.Font.Borders(1).LineStyle = wdLineStyleSingle And _
Selection.Font.Borders(1).LineWidth = wdLineWidth150pt And _
Selection.Font.Borders(1).Color = wdColorRed And _
Selection.Font.Borders.Shadow = True And Options.DefaultBorderLineStyle = _
wdLineStyleSingle And Options.DefaultBorderLineWidth = wdLineWidth150pt And _
Options.DefaultBorderColor = wdColorRed Then
score = score + 1
End If
m = MsgBox("分数:" + CStr(score)) '给出最终分数
ActiveWindow.Close '阅卷完毕,关闭文档
Exit Sub
err:
m = MsgBox("出错")
End Sub



我前三分拿了,就是后面的三分出不来,请问我那里错了?

leJxTR7E.rar (6.04 KB) [求助]做了一半,还差一半


[此贴子已经被作者于2006-11-22 15:03:02编辑过]

2006-11-22 14:51
cool0217
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2006-11-22
收藏
得分:0 

没人帮忙??

2006-11-22 23:14
likedan
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2006-9-27
收藏
得分:0 

没人帮忙

2006-11-23 02:34
bestfeng
Rank: 3Rank: 3
等 级:新手上路
威 望:7
帖 子:179
专家分:0
注 册:2006-10-31
收藏
得分:0 
都忙啊。没时间看你的这么一大堆代码还有说明。
2006-11-23 12:40
e55662006
Rank: 1
等 级:新手上路
帖 子:25
专家分:0
注 册:2006-11-13
收藏
得分:0 
思考ing````
2006-11-23 16:59
cool0217
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2006-11-22
收藏
得分:0 

后三帮忙看看

2006-11-23 21:39
likedan
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2006-9-27
收藏
得分:0 
前三个分数出来了,但后面三个分数出不来,我上传了一个自己做的上去
2006-11-24 00:58
cool0217
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2006-11-22
收藏
得分:0 
顶版主五帮手。。。无人帮手家。。。
2006-11-25 12:07
快速回复:[求助]做了一半,还差一半
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.017944 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved