|
试试这个,先运行test程序:
- Sub test()
- On Error Resume Next
- Call InsertAskAndAnswer
- Application.OnTime Now + 0.000002, "test"
- DoEvents
- End Sub
- Function InsertAskAndAnswer()
- Dim s As Long, n As Long, Myrange As Range
- s = Selection.Paragraphs(1).Range.End
- Set Myrange = ActiveDocument.Range(0, s)
- n = Myrange.Paragraphs.Count
- If Len(ActiveDocument.Paragraphs(n).Range.Text) = 1 Then
- If n = 1 Then
- Selection.InsertAfter Text:="问:"
- Selection.MoveDown unit:=wdParagraph
- Else
- If Left(ActiveDocument.Paragraphs(n - 1).Range.Text, 2) = "问:" Then
- Selection.InsertAfter Text:="答:"
- Selection.MoveDown unit:=wdParagraph
- Else
- Selection.InsertAfter Text:="问:"
- Selection.MoveDown unit:=wdParagraph
- End If
- End If
- End If
- End Function
复制代码
|
|