MS字 - 搜索关键词并删除句子 [英] MS word - search key words and delete the sentence

查看:93
本文介绍了MS字 - 搜索关键词并删除句子的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是老师,我需要编辑一个问题库文件。问题后面的答案如下:



问题1.选择X的最佳描述

a。 [描述1]

b。 [描述2]

c。 [描述3]

d。 [描述4]



答案c



问题2.选择........ ...



答案d





常规问题搜索和替换仅适用于答案一词,但不适用于整个句子以包含实际答案。我尝试了各种宏,但找不到一个选择整行。请帮忙。



我的尝试:



Hi, I am a teacher, and I need to edit a question bank document. The answers follow immediately after questions as following:

Question 1. Choose the best description of "X"
a. [description 1]
b. [description 2]
c. [description 3]
d. [description 4]

Answer c

Question 2. Choose...........

Answer d


The problem with the regular search and replace only works for the word 'Answer' but not the whole sentence to include the actual answer. I tried various macros but cannot find one to select the entire row. please help.

What I have tried:

Set myRange = ActiveDocument.Range(Start:=0, End:=Selection.End) 
For Each aWord In myRange.Words 
 If aWord.Text = "Answer " Then aWord.Delete 
Next aWord

推荐答案

答案由两个单词组成。



当Text =Answer时,删除当前单词和next单词。



然后继续下一个问题。
The "Answer" consists of TWO "words".

When Text = "Answer", delete current word AND "next" word.

Then continue with next question.


这样的事情:

Something like this:
Sub DeleteAnswers()
	Dim oRng As Word.Range
	Set oRng = ActiveDocument.Range
	With oRng.Find
		.Text = "Answer"
		While .Execute
			With oRng.Paragraphs(1).Range
			If .Characters(1) = "Answer" Then .Delete
			End With
		Wend
	End With
End Sub


这篇关于MS字 - 搜索关键词并删除句子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆