troubleshooting Question

In Word VBA, how to combine one selection to another selection executed from find

Avatar of Ashish Bist
Ashish Bist asked on
10 Comments1 Solution275 ViewsLast Modified:
I have a document where question and answer have different styles assigned to each (for question "*Questions" and for answer "Normal"), answer can have multiple paragraphs or even image, so basically I need code to find/search a particular word in document and when found, code need to select from start of that question till the end of its answer (or start of next question). I have code in break but somehow could not able to compile it (not able to combine selection form Previous_Question till Next_Question). code goes like this:

 Sub Previous_Question()

 Selection.Find.Style = "*Questions"
 Selection.Find.Forward = False

 End Sub

 Sub Next_Question()

 Selection.Find.Style = "*Questions"
 Selection.Find.Forward = True

 End Sub

 Sub Find_Word()

 With Selection.Find
 .Text = InputBox(sPrompt, sTitle, sDefault)
 End With
 Do While Selection.Find.Execute
 Selection.StartOf Unit:=wdParagraph

 Selection.MoveEnd Unit:=wdParagraph
 sBigString = sBigString + Selection.Text
 Selection.MoveStart Unit:=wdParagraph
 Documents.Add DocumentType:=wdNewBlankDocument
 Selection.InsertAfter (sBigString)

 End Sub
Please help!!!

Edit: Code put into a snippet box using the CODE item in the comment editor toolbar. GrahamSkan

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Top Expert 2012

The Distinguished Expert awards are presented to the top veteran and rookie experts to earn the most points in the top 50 topics.

Join our community to see this answer!
Unlock 1 Answer and 10 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 10 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros