Importing Text with Indexes

K

Kevin

I want to import a text file, from a database, that contains the coding to
setup indexes in Word.
When the text file contains { XE "Bloggs" \f"n" } Word does not recognise it
as an index.
Is there a special control character I have to insert into the text file so
Word will index the documnet correctly?
 
P

Peter T. Daniels

The index markers ({XE }) are field codes, inserted as such, not just
brace-characters. If it's really a .txt file, then the index markers
won't carry over.
 
S

Suzanne S. Barnhill

But it should be possible for some clever person to write a macro that
searches for text surrounded by braces, removes the braces, and then
converts the selected text to a field.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
http://word.mvps.org

The index markers ({XE }) are field codes, inserted as such, not just
brace-characters. If it's really a .txt file, then the index markers
won't carry over.
 
G

Graham Mayor

Not that clever :)

Sub ReformatXE()
Dim rXE As Range
Selection.HomeKey wdStory
Selection.Find.ClearFormatting
With Selection.Find
Do While .Execute(findText:="\{ XE*\}", _
MatchWildcards:=True, _
Wrap:=wdFindStop, Forward:=True) = True
Set rXE = Selection.Range
rXE.Text = Replace(rXE, "{ XE", "")
rXE.Text = Replace(rXE, " }", "")
MsgBox rXE
rXE.Fields.Add rXE, _
wdFieldIndexEntry, _
rXE.Text, _
False
Loop
End With
End Sub

If the fields are entered as text as { XE "Bloggs" \f"n" }, the above should
do the job
http://www.gmayor.com/installing_macro.htm

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.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