Bạn thử cái sub này xem (làm theo kiểu record macro cho nên chắc là chưa tối ưu).
Để áp dụng được thì cần phải thỏa tất cả điều kiện sau:
1+ mỗi câu hỏi có 4 đáp án
2+ mỗi đáp án chỉ chiếm 1 dòng
3+ 4 đáp án chiếm 4 dòng kế tiếp nhau
4+ 4 đáp án bắt đầu bằng các ký tự “a.” “b.” c.” d.”
5+ số chạy vòng lặp đủ dư để chạy hết tất cả các dòng
6+ thêm vào cuối bài 4 dòng chứa các ký tự “zz”
Nếu không thỏa được các điều kiện trên thì sub này không dùng được; tùy tình trạng mà chỉnh sửa.
Mục 6+ là do tôi không biết chọn điểm cuối file để dừng vòng lặp; bạn chỉnh lại cho phù hợp.
Cách chọn dòng và chọn ký tự có vẻ thủ công nên vòng lặp có vẻ làm việc nhiều.
Tôi chạy thử khoảng 1.500 câu thì máy tôi mất chừng một phút.
Thử nhanh nên chẳng Option Explicit.
Sub Dong()
ActiveDocument.Range(0, 0).Select
For i = 1 To 50000
Selection.MoveDown Unit:=wdLine, Count:=1
Selection.EndKey Unit:=wdLine, Extend:=wdExtend
a = Selection
Selection.HomeKey
Selection.MoveDown Unit:=wdLine, Count:=1
Selection.EndKey Unit:=wdLine, Extend:=wdExtend
b = Selection
Selection.HomeKey
Selection.MoveDown Unit:=wdLine, Count:=1
Selection.EndKey Unit:=wdLine, Extend:=wdExtend
c = Selection
Selection.HomeKey
Selection.MoveDown Unit:=wdLine, Count:=1
Selection.EndKey Unit:=wdLine, Extend:=wdExtend
d = Selection
x = Left(a, 2) & Left(b, 2) & Left(c, 2) & Left(d, 2)
If x = "zzzzzzzz" Then Exit For
If x = "a.b.c.d." Then
y = a & b & c & d
y = Replace(y, Chr(13), "; ")
y = Left(y, Len(y) - 2)
Selection.MoveUp Unit:=wdLine, Count:=3
Selection.MoveDown Unit:=wdLine, Count:=4, Extend:=wdExtend
Selection.TypeText Text:=y
Else
Selection.MoveUp Unit:=wdLine, Count:=3
End If
Next i
MsgBox i
End Sub
42. "My friend was going to call me as soon as he arrived this morning, but he
didn't call." "He ....................... the train."
a. had to miss
b. should have missed
c. would have missed
d. must have missed
--> d
43. He wasn’t responsible. He wasn’t .............
a. blame
b. to blame
c. blaming
d. for blame
--> b
44. She went to a seaside resort because she was .................. on water-skiing.
a. keen
b. enthusiastic
c. interested
d. like
--> a
zz
zz
zz
zz
Để áp dụng được thì cần phải thỏa tất cả điều kiện sau:
1+ mỗi câu hỏi có 4 đáp án
2+ mỗi đáp án chỉ chiếm 1 dòng
3+ 4 đáp án chiếm 4 dòng kế tiếp nhau
4+ 4 đáp án bắt đầu bằng các ký tự “a.” “b.” c.” d.”
5+ số chạy vòng lặp đủ dư để chạy hết tất cả các dòng
6+ thêm vào cuối bài 4 dòng chứa các ký tự “zz”
Nếu không thỏa được các điều kiện trên thì sub này không dùng được; tùy tình trạng mà chỉnh sửa.
Mục 6+ là do tôi không biết chọn điểm cuối file để dừng vòng lặp; bạn chỉnh lại cho phù hợp.
Cách chọn dòng và chọn ký tự có vẻ thủ công nên vòng lặp có vẻ làm việc nhiều.
Tôi chạy thử khoảng 1.500 câu thì máy tôi mất chừng một phút.
Thử nhanh nên chẳng Option Explicit.
Sub Dong()
ActiveDocument.Range(0, 0).Select
For i = 1 To 50000
Selection.MoveDown Unit:=wdLine, Count:=1
Selection.EndKey Unit:=wdLine, Extend:=wdExtend
a = Selection
Selection.HomeKey
Selection.MoveDown Unit:=wdLine, Count:=1
Selection.EndKey Unit:=wdLine, Extend:=wdExtend
b = Selection
Selection.HomeKey
Selection.MoveDown Unit:=wdLine, Count:=1
Selection.EndKey Unit:=wdLine, Extend:=wdExtend
c = Selection
Selection.HomeKey
Selection.MoveDown Unit:=wdLine, Count:=1
Selection.EndKey Unit:=wdLine, Extend:=wdExtend
d = Selection
x = Left(a, 2) & Left(b, 2) & Left(c, 2) & Left(d, 2)
If x = "zzzzzzzz" Then Exit For
If x = "a.b.c.d." Then
y = a & b & c & d
y = Replace(y, Chr(13), "; ")
y = Left(y, Len(y) - 2)
Selection.MoveUp Unit:=wdLine, Count:=3
Selection.MoveDown Unit:=wdLine, Count:=4, Extend:=wdExtend
Selection.TypeText Text:=y
Else
Selection.MoveUp Unit:=wdLine, Count:=3
End If
Next i
MsgBox i
End Sub
42. "My friend was going to call me as soon as he arrived this morning, but he
didn't call." "He ....................... the train."
a. had to miss
b. should have missed
c. would have missed
d. must have missed
--> d
43. He wasn’t responsible. He wasn’t .............
a. blame
b. to blame
c. blaming
d. for blame
--> b
44. She went to a seaside resort because she was .................. on water-skiing.
a. keen
b. enthusiastic
c. interested
d. like
--> a
zz
zz
zz
zz