Teaching assignments

A

ArthurN

Hi,
I have this long document of new words for my language students I would like
to transform. Here's the basic document structure, which is repeated
throughout:
Topic (h1 element, there're over 200 topics now)
Glossary (h2)
Comprehension questions (h2)
----------------------------
I need help with the glossary section, which has the following structure:
word 1- definition
*a sentence with the example of the usage (actually starts with "*")
word 2- definition
*another sentence
 
D

Doug Robbins - Word MVP

The following code should do what you want:

Dim myrange As Range
Dim rngGlossary As Range
Dim i As Long, j As Long
Selection.HomeKey wdStory
Selection.Find.ClearFormatting
With Selection.Find
Do While .Execute(FindText:="Glossary", Forward:=True, _
MatchWildcards:=False, Wrap:=wdFindStop, MatchCase:=False) = True
Set myrange = Selection.Range
myrange.End = ActiveDocument.Range.End
Set rngGlossary = Selection.Range.Duplicate
rngGlossary.Collapse wdCollapseEnd
For i = 2 To myrange.Paragraphs.Count
If myrange.Paragraphs(i).Style <> "Heading 2" Then
rngGlossary.End = myrange.Paragraphs(i).Range.End
Else
Exit For
End If
Next i
rngGlossary.Start = rngGlossary.Start + 2
j = rngGlossary.Paragraphs.Count
For i = 2 To j Step 2
rngGlossary.Paragraphs(j).Range.InsertBefore
rngGlossary.Paragraphs(i).Range.Text
Next i
For i = 2 To j Step 2
rngGlossary.Paragraphs(i).Range.Delete
Next i
Selection.Collapse wdCollapseEnd
Selection.MoveRight wdCharacter, 1
Loop
End With


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top