View Single Post
 
Old 12-07-2014, 01:44 PM
frustrated teacher frustrated teacher is offline Windows 7 64bit Office 2010 64bit
Novice
 
Join Date: May 2014
Posts: 12
frustrated teacher is on a distinguished road
Default Delete starting number *) and delete Unneeded data in series

Hello friends,

It's another year of exams for my students and I am stuck trying to upload an exam to our antiquated system.

The exam system takes a particular format, I figured out how to upload the questions, but not the answers.

The questions are in plain text, no tables that I can see.

1) This is a question #1.
A) cat
B) dog
C) mouse
D) bird
Answer: C

11) This is a question #11.
A) cat
B) dog
C) mouse
D) bird
Answer: B

Ideally, I would like it to look like:

This is question #1. Answer: C) mouse

This is question #11. Answer: B) dog

What I've tried: I've used search functions

"Find what": ^13[0-9]
"Replace with": ^p

But that only deletes one number at a time and does not delete the ")"

Ive tried:
Code:
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
  .Text = "*\)" <<< and variations
  .Replacement.Text = ""
  .Forward = True
  .Format = False
  .MatchCase = False
  .MatchWholeWord = False
  .MatchWildcards = True
  .MatchSoundsLike = False
  .MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
But it doesnt seem to like the ")"

I know how to get RID of whole lines using a variation of:
Code:
Dim oRng As Word.Range
Dim oRngDelete As Word.Range
Set oRng = ActiveDocument.Range
With oRng.Find
  .Text = "word"
  While .Execute
    oRng.Select
    Set oRngDelete = ActiveDocument.Bookmarks("\Line").Range
    oRngDelete.Delete
  Wend
End With
End Sub
 
Sub ScratchMacroII()
Dim oRng As Word.Range
Set oRng = ActiveDocument.Range
With oRng.Find
  .Text = "word"
  While .Execute
  oRng.Paragraphs(1).Range.Delete
  Wend
End With
End Sub
But I'm still stuck on how to automatically "chose the right whole answer" and not just the letter of the right answer

Last edited by macropod; 12-07-2014 at 04:04 PM. Reason: Added code tags & formatting
Reply With Quote