Results 1 to 7 of 7
  1. #1
    3 Star Lounger
    Join Date
    Jan 2007
    Location
    Massachusetts, USA
    Posts
    272
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Macro to rename REF codes (MS Word 2003 (SP3))

    Hello,

    I would like to find a macro (if possible) that will point to a folder full of MS Word .DOC files and:

    1. Rename all of the Table and Figure REF field codes to the ACTUAL NAME you would see in a printed book, while keeping the field codes intact.
    2. Display only the Table and Figure field codes (within the field code) and nothing else trailing after the code, such as the name of the graphic or figure title or table title.

    For example:

    {REF _Ref149008481 h } will become {Table 1 h } or {REF _Table 1 h }
    {REF _Ref147635334 h } will become {Table 2 h } or {REF _Table 2 h }


    (Figure {REF Fig_Router_Front h * MERGEFORMAT}) will become (Figure {REF Figure 1 h * MERGEFORMAT})
    (Figure {REF Fig_Router_Rear h * MERGEFORMAT}) will become (Figure {REF Figure 2 h * MERGEFORMAT})


    I need to bring these documents into Adobe FrameMaker 8.

    In FrameMaker 8, the imported .DOC file displays a (Figure 1) cross reference as (1) and a (Table 1) cross reference as (1) .

    Is there a way to ensure that the word "Figure" and the word "Table" are preserved, so that I get (Figure 1) and (Table 1) after
    the document has been imported into FrameMaker.


    Also, when I look up a Figure and/or Table cross reference in FrameMaker, all I see are Ref149008481 types of numbers. I would like to
    run fix that with the macro in MS Word first, so that I do not see Refxxxxxxxxx numbers but rather the actual Figure or Table cross reference number - from the Cross Reference window in FrameMaker.


    Hopefully, I have explained this clearly. If not please let me know and I will try to re-word my macro request.


    Thanks in advance for any suggestions.

    Regards,

    Jim

  2. #2
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,852
    Thanks
    4
    Thanked 259 Times in 239 Posts

    Re: Macro to rename REF codes (MS Word 2003 (SP3))

    I haven't seen a macro to do this but it could well exist - this forum is not a great location for Framemaker specific code. You might have more luck on a Framemaker specific forum since it is far more common in that area to import Word documents. The following represents my thoughts on achieving the task but I can't provide specific code assistance as I don't have Framemaker loaded anymore.

    If you want the automatic cross references to work in Framemaker then you need to work on not just the cross-reference but also the anchor. To do this, you need to understand a few things about how Word and Framemaker perform the tasks of Cross-Referencing. Both applications do this in much the same way but Word does it covertly and Framemaker overtly.

    Framemaker: First step is to create an anchor for something that you want to cross-refer to (this in analogous to a bookmark in Word). Next, you create the link to the named anchor and tell it what type of link you want eg page number, page location etc

    Word: Open the cross-ref dialog and choose the element you are creating a cross reference to and what type of link you are getting. Now when you click OK, Word puts a hidden bookmark in the anchor location and then puts a cross-ref to that bookmark with the chosen link type data.

    So, if you want the conversion from Word to Framemaker to honour this automation, you need to first find a way to translate the hidden (and not hidden) bookmarks into named anchors. You may be able to work out how to do this by exporting a Frame file to RTF / MIF / XML or whatever format you are using to import into Frame and seeing what Frame needs to import to get named anchors in there. Once you get this part working, the second step is working out how to bring in the cross-references. Without the first step, the second step is doomed to fail.

    An easier path may be to convert the automated cross refs in Word to hard coded (perhaps with an included hook) before importing to Frame and then running a script within Frame that searches the text to build the cross-references afresh using Framemakers tools.
    Andrew Lockton, Chrysalis Design, Melbourne Australia

  3. #3
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,054
    Thanks
    2
    Thanked 417 Times in 346 Posts

    Re: Macro to rename REF codes (MS Word 2003 (SP3))

    Hi James,

    There's a couple more things you need to know about Word:

    1. Bookmark names cannot have spaces in them. Consequently, you can't replace the bookmark named "_Ref149008481" with "Table 1" or "_Table 1", or the corresponding cross-references from {REF _Ref149008481 h } to {Table 1 h } or {REF _Table 1 h }. You could use "Table " or "Table_1" as the bookmark name.

    2. An underscore at the starte of a bookmark name (eg "_Ref149008481"), simply tells Word to treat it as hidden, under normal circumstances. I have no idea of how Framemeker regards such things.

    3. You can't simply rename a bookmark - you have to create an entirely new bookmark and delete the old one. That's no big deal - you just have to look up the desired cross-reference to the bookmark you want to change, assign a new bookmark name to the object/range, delete the old bookmark (be cautious not to delete one that's needed in other contexts (eg the TOC)) and replace the bookmark name in all the related cross-references (again being careful about contexts).
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  4. #4
    3 Star Lounger
    Join Date
    Jan 2007
    Location
    Massachusetts, USA
    Posts
    272
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Re: Macro to rename REF codes (MS Word 2003 (SP3))

    Hello Paul,

    Thanks for the posting. Okay, now that I have a better understanding of bookmarks, do you how to:

    1. Find "_Ref149008481" and the table number associated with it (e.g. Table 1).
    2. Create new bookmark (as you say) called: "Table_1".
    3. Delete old bookmark "_REF149008481".
    4. Repeat steps 1,2 and 3 for figure cross references: (Figure {REF Fig_*

    I know this is a Microsoft Office Word forum and this topic is related to MS Word 2003 - as I am trying to convert ALL of my bookmarks to a (Table 1 2 3 Figure 1 2 3) format. This will allow me to quickly find these bookmarks in another application (e.g. Adobe FrameMaker 8).

    I NEED help in finding a macro solution asap and welcome any/all input. I have thousands of bookmarks (cross references to process)

    Thanks in advance for your assistance.

    Regards,

    -J

  5. #5
    3 Star Lounger
    Join Date
    Jan 2007
    Location
    Massachusetts, USA
    Posts
    272
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Re: Macro to rename REF codes (MS Word 2003 (SP3))

    Hello Andrew,

    Thanks as always for your excellent suggestions. Please see my reply to macropod.
    Thanks,
    Jim

  6. #6
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,054
    Thanks
    2
    Thanked 417 Times in 346 Posts

    Re: Macro to rename REF codes (MS Word 2003 (SP3))

    Hi Jim,

    The first thing you'll want to do is to expose all the field codes. You can toggle their display via Alt-F9.

    Q1. Find "_Ref149008481" and the table number associated with it (e.g. Table 1).
    A: To find a bookmarked range, use Edit|Goto (F5) > Bookmark > Bookmark name. You can also do this via Insert|Bookmark > Name > Goto, but you'll need to check the 'Hidden bookmarks' box to be able to select those starting with '_'.

    Q2. Create new bookmark (as you say) called: "Table_1".
    A: Since the previous step will have selected/highlighted the whole of the bookmark name, simply use Insert|Bookmark > Bookmark Name > Add to create the new one.

    You'll then need to use Find/Replace to change all references to the old bookmark name to the new one, but keep in mind the caveats in my previous post because you could break Word's functionality with the document if you replace the wrong ones.

    Q3. Delete old bookmark "_REF149008481".
    A: Use Insert|Bookmark > Bookmark Name > Delete, with the the 'Hidden bookmarks' box checked. Again, keep in mind the caveats in my previous post.

    4. Repeat steps 1,2 and 3 for figure cross references: (Figure {REF Fig_*
    A: Repeat for each bookmark that you want to replace.

    I don't think a macro will speed this up much unless you've got really large numbers of bookmarks (not cross-references) to process - and you're still going to have to supply the macro with both the old and new bookmark names and choose which cross-references to replace and delete.
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  7. #7
    3 Star Lounger
    Join Date
    Jan 2007
    Location
    Massachusetts, USA
    Posts
    272
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Re: Macro to rename REF codes (MS Word 2003 (SP3))

    Hi Paul,

    Thanks for the quick response. I appreciate it.
    I will give this a whirl and see what happens, when I have a chance.

    Thanks again for your assistance.

    Regards,

    Jim

Posting Permissions

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