Index Entry Field Code (XE), Switches & Macros

M

Michael Anhorn

I'm wondering if there is any way to create a macro or a
quick key (ie CTRL W) so that I can select text and
insert a field code for index entries.

The specific field codes I would like to be able to
easily inserted is:

1) {XE "selected text" \f "a"}
2) {XE "selected text" \f "b"}

Any suggestions would be greatly appreciated
Michael
 
P

Peter Jamieson

Have a look at Autotext in Word Help (create an autotext for each thing you
want to insert often, and assign a keystroke to it).
 
C

Cindy M -WordMVP-

Hi Michael,
I'm wondering if there is any way to create a macro or a
quick key (ie CTRL W) so that I can select text and
insert a field code for index entries.
Something along these lines should work:

Sub InsertXEfield()
Dim szEntry as String
szEntry = Selection.Range.Text
Selection.Collapse wdCollapseEnd
ActiveDocument.Fields.Add _
Range:=Selection.Range, _
Text:=" XE " & Chr$(34) & _
szEntry & Chr$(34) & " /f" _
& Chr$(34) & "a" & Chr$(34),_
PreserveFormatting:=False
End Sub


Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update
Sep 30 2003)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any
follow question or reply in the newsgroup and not by e-mail
:)
 
M

Michael

Hi Cindy,

Thanks for this. I tried copying and pasting this into a
Macro and wasn't able to get it to work. I don't have
any background in programming so am not able to debug
it. But I can tell you that when I pasted it everything
from "ActiveDocument.Fields.Add _" and on was red. Any
help you could give me would be most appreciated.

Thanks
Michael
 
C

Cindy M -WordMVP-

Hi Michael,

whoops! Looks like something got "lost in translation". I
did some editing to make sure it wouldn't break in the
wrong place due to wrapping, and it looks like I deleted
something I ought not have! Sorry about that. Try this

Sub InsertXEfield()
Dim szEntry As String
szEntry = Selection.Range.Text
Selection.Collapse wdCollapseEnd
ActiveDocument.Fields.Add _
Range:=Selection.Range, _
Type:=wdFieldEmpty, _
Text:=" XE " & Chr$(34) & _
szEntry & Chr$(34) & " /f" _
& Chr$(34) & "a" & Chr$(34), _
PreserveFormatting:=False
End Sub
I tried copying and pasting this into a
Macro and wasn't able to get it to work. I don't have
any background in programming so am not able to debug
it. But I can tell you that when I pasted it everything
from "ActiveDocument.Fields.Add _" and on was red. Any
help you could give me would be most appreciated.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update
Sep 30 2003)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any
follow question or reply in the newsgroup and not by e-mail
:)
 
M

Michael

Brilliant!

Thank you very much!
Michael
-----Original Message-----
Hi Michael,

whoops! Looks like something got "lost in translation". I
did some editing to make sure it wouldn't break in the
wrong place due to wrapping, and it looks like I deleted
something I ought not have! Sorry about that. Try this

Sub InsertXEfield()
Dim szEntry As String
szEntry = Selection.Range.Text
Selection.Collapse wdCollapseEnd
ActiveDocument.Fields.Add _
Range:=Selection.Range, _
Type:=wdFieldEmpty, _
Text:=" XE " & Chr$(34) & _
szEntry & Chr$(34) & " /f" _
& Chr$(34) & "a" & Chr$(34), _
PreserveFormatting:=False
End Sub


Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update
Sep 30 2003)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any
follow question or reply in the newsgroup and not by e- mail
:)

.
 

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