+ Reply to Thread
Results 1 to 3 of 3
  1. #1
    Valued Forum Contributor
    Join Date
    03-23-2008
    Location
    Tennessee
    MS-Off Ver
    Office 2007
    Posts
    519

    Macro to add index entries

    Greetings, Gurus. I am trying to help automate the task of adding index entries in MS Word 2007. Unfortunately, I know NOTHING about Word macros.

    In the below macro, I have selected the word "warehouse", then recorded the steps to adding "warehouse" to the index. Ideally I would like to select another word, run the macro, and THAT word would be added to the index. Unfortunately, that isn't happening.

    Here's what I've got. Can someone help me to add the SELECTED word to the index?

    Thanks in advance.

    Code:
    Sub Add_to_Index()
        ActiveWindow.ActivePane.View.ShowAll = True
        ActiveDocument.Indexes.MarkAllEntries Range:=Selection.Range, Entry:= _
            "warehouse", EntryAutoText:="warehouse", CrossReference:="", _
            CrossReferenceAutoText:="", BookmarkName:="", Bold:=False, Italic:=False
        ActiveWindow.ActivePane.View.ShowAll = Not ActiveWindow.ActivePane.View. _
            ShowAll
    End Sub
    Last edited by hutch@edge.net; 06-23-2009 at 01:02 PM.

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    2003 & 2007 & 2010
    Posts
    10,924

    Re: Macro to add index entries

    Like this maybe.

    Code:
    Sub Add_to_Index()
        ActiveDocument.Indexes.MarkAllEntries Range:=Selection.Range, _
                        Entry:=Selection.Range.Text, _
                        EntryAutoText:=Selection.Range.Text, _
                        CrossReference:="", CrossReferenceAutoText:="", BookmarkName:="", _
                        Bold:=False, Italic:=False
    End Sub
    Cheers
    Andy
    www.andypope.info

  3. #3
    Valued Forum Contributor
    Join Date
    03-23-2008
    Location
    Tennessee
    MS-Off Ver
    Office 2007
    Posts
    519

    Re: Macro to add index entries

    Perfect, Andy. Thanks.

    Have a good one!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.2.0