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

    Conversion of Fig and Table REF to text (MS Word 2003 SP3)

    Hello,

    I am looking for a macro that will:

    1. Point to a folder full of word documents (MS Word 2003) .DOC files and open each document.

    2. Search through each document and flatten out each field code to flat text, such as seen in a printed book. For example, this figure cross reference: (Figure {REF Fig_Router h}) becomes Figure X. Router where X = whatever the figure number happens to be.

    3. Next, I have 30 styles that I want to change to a new format. If you show me how to do it for one style, then I can add in the lines for the additional styles.

    Here is one style change example:

    From: Paragraph text
    To: Para Text


    Thanks in advance for any assistance provided.


    Regards,


    Jim

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Conversion of Fig and Table REF to text (MS Wo

    For #2, you can convert all fields to results (unlink the fields) easily in one step. However, if you want to preserve some fields as codes, you will need to examine them individually. I'm not sure how you will know which REF fields you want to unlink and which should remain as field codes. What is the pattern?

    For #3, can you use find and replace? Try it interactively and see whether you get the results you want.

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

    Re: Conversion of Fig and Table REF to text (MS Wo

    [For #2, you can convert all fields to results (unlink the fields) easily in one step. However, if you want to preserve some fields as codes, you will need to examine them individually. I'm not sure how you will know which REF fields you want to unlink and which should remain as field codes. What is the pattern?]

    I only want to unlink all following:

    Figures
    Figure Titles
    Table Titles
    Figure Cross References
    Table Cross References

    In the end, the MS Word file will be saved and brought into FrameMaker 8. Right now, if I bring it into FrameMaker 8 (as is), I get a lot of junk where those references were. So, I wish to flatten it out first, then bring it into FrameMaker and use a Find/Change (inside FrameMaker).

    As for the styles, now that I think about it, the formatting in MS Word mimics the formatting in FrameMaker. So, I only need to have a macro that will go through all the styles in all of the documents and rename the style (e.g. Paragraph text style becomes the Para Text style and so forth). I have about 40 styles and will need to add ( I guess) 40 lines of code.


    I found some code, and modified it (wild guess) listed below.

    Sub ReplaceInDoc(doc As Document)
    ActiveWindow.View.ShowFieldCodes = True
    doc.Content.Find.Execute Find Style:="Paragraph Text", RenameWith:="Para Text ", Replace:=wdReplaceAll
    doc.Fields.Update
    ActiveWindow.View.ShowFieldCodes = False
    End Sub


    Could I use this code (provided it is correct) in my macro? What would I need in this macro, to make it work?

    Thanks in advance for your help. It is very much appreciated.

    Regards,

    Jim

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Conversion of Fig and Table REF to text (MS Wo

    When replacing styles, there is no need to show then hide field codes, nor to update fields - styles are differen from fields. The line

    doc.Content.Find.Execute Find Style:="Paragraph Text", RenameWith:="Para Text ", Replace:=wdReplaceAll

    makes no sense - please read the built-in help for Find. Perhaps this:

    Sub ReplaceInDoc(doc As Document)
    With doc.Content.Find
    .Text = ""
    .Replacement.Text = ""
    .ClearFormatting
    .Replacement.ClearFormatting
    .Style = "Paragraph Text"
    .Replacement.Style = "Para Text"
    .Execute Replace:=wdReplaceAll
    End With
    End Sub

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

    Re: Conversion of Fig and Table REF to text (MS Wo

    Thanks Hans,

    I will try your code today.

    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
  •