VBA if 后不能执行msgbox
Word 文件的第一行的第三个字符为空,所以ThisDocument.Words.Item(2) Is Not Null 为真,但是函数报错
Sub aa()
Dim A As Integer
A = 5 * 5
MsgBox A
If ThisDocument.Words.Item(5) <> Null Then
SaveAs ThisDocument.Words.Item(1) & ThisDocument.Words.Item(2) & ThisDocument.Words.Item(3) & ThisDocument.Words.Item(4) & ThisDocument.Words.Item(5) & ".doc"
ElseIf ThisDocument.Words.Item(4) <> Null Then
SaveAs ThisDocument.Words.Item(1) & ThisDocument.Words.Item(2) & ThisDocument.Words.Item(3) & ThisDocument.Words.Item(4) & ".doc"
ElseIf ThisDocument.Words.Item(3) <> Null Then
SaveAs ThisDocument.Words.Item(1) & ThisDocument.Words.Item(2) & ThisDocument.Words.Item(3) & ".doc"
ElseIf ThisDocument.Words.Item(2) Is Not Null Then
A = 5 * 5
MsgBox A
'SaveAs ThisDocument.Words.Item(1) & ThisDocument.Words.Item(2) & ".doc"
Else
SaveAs ThisDocument.Words.Item(1) & ".doc"
End If
End Sub
当我执行到A = 5 * 5有错误:
Run-time error '424':
Object required
是什么原因?