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

    Macro to remove ' from INCLUDEPICTURE fields (MS Word 2003, SP2)

    Hello,
    I am trying to bring .doc files (MS Word 2003) into Adobe FrameMaker 8. Everything is working okay except that evidently FM8 cannot parse the and as a result the .fm file is filled with grey boxes.
    Adobe FrameMaker does not offer the useful (readily available) Macros that are found in MS Word. So, I need to find a way (if possible) to remove the and replace with a manual space. I know that the field code see the code as a physical space, but that seems to keep the graphics from being referenced into FM8, once the .doc file is opened in FM8 and saved as a .fm file. The end goal is to eliminate have to status thousands of graphics in FM8 with the "MISSING FILE" popup. So, I need a Macro that will point to a folder full of word documents, remove the code and somehow put just a space in that field code path. Hmm, even if the graphic path is broken, this may be good enough for FrameMaker to ingest all of the referenced graphics. Thanks for your assistance. Jim

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

    Re: Macro to remove ' from INCLUDEPICTURE fields (MS Word 2003, SP2)

    Woody's Lounge uses HTML to display pages. HTML treats multiple spaces as a single space. As a consequence, it is not clear what you mean. Could you try to explain in words?

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

    Re: Macro to remove ' from INCLUDEPICTURE fields (MS Word 2003, SP2)

    Hello Hans,

    I need a macro that will point to a folder full of word documents, find two types of INCLUDEPICTURE field codes and remove the code which is how Microsoft handles a space in the filename. The end result is that the space in the file name will remain, but not the . I have attached a screen shot that better illustrates what I need in the Macro. Thanks so much for your assistance. It is very much appreciated.
    Regards,

    Jim
    Attached Images Attached Images

  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 remove ' from INCLUDEPICTURE fields (MS Word 2003, SP2)

    The caption bubble in my screen shot got cropped by mistake.

    Anyway, the macro should remove the percentage twenty code from both the INSERT AND LINK and LINK TO FILE fieldcodes found in the folder full of word documents.

    Thanks once again.

    Jim

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

    Re: Macro to remove ' from INCLUDEPICTURE fields (MS Word 2003, SP2)

    Is there any chance that the documents will contain instances of %20 anywhere in the text that should *not* be replaced with a space?

    Note: the trick to prevent % followed by 20 from being converted to a space is to place square brackets around the % sign: <!t>[%]<!/t>20 will be displayed as %20.

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

    Re: Macro to remove ' from INCLUDEPICTURE fields (MS Word 2003, SP2)

    Hans,

    I am not sure about the thirty seven character set you mentioned, but if you look at the screen shot I submitted earlier, all of my field codes (in all of my docs) are based on the percentage twenty code.

    I need to remove this percentage twenty and keep a space there as some graphic file names are made up of two or more words. I cannot use any other codes there in that space, only the manual space entry.

    The reason for this is that I am opening all the word documents into FrameMaker 8 and saving them as FrameMaker files. FrameMaker does NOT like the percentage twenty in the field code. It does see that code, the way Microsoft sees it.

    In a test experiment. I ran a find in replace (CTRL H) in one of my documents and removed all the percentage twenty code entries within the INCLUDE picture fields. Next, I replaced the entry by entering a manual space in the Replace With field (see screen shot).

    It would be great if a MACRO could do this (looking only for INCLUDEPICTURE fields) and then replace the percentage twenty entries with manual spaces.

    For now, I can open each word document, CTRL H and then replace my way through all of the INCLUDEPICTURE fields. Once that is done, FrameMaker will THEN be able to open the entire MS Word document into FrameMaker, complete with all the graphics that were referenced (linked) into the original word document.

    If a Macro can be created to do this, then that would be great, otherwise I can open each word document myself and CTRL H my way through the INCLUDEPICTURE fields, save it and then open it in FrameMaker 8 without any problems.

    Thanks as always.

    Regards,

    Jim
    Attached Images Attached Images

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

    Re: Macro to remove ' from INCLUDEPICTURE fields (MS Word 2003, SP2)

    Try the following on a copy of the folder with the documents first.

    See <post:=703,225>post 703,225</post:> for the general idea. Change the ReplaceInDoc procedure from that post to

    Sub ReplaceInDoc(doc As Document)
    ActiveWindow.View.ShowFieldCodes = True
    doc.Content.Find.Execute FindText:="%20", ReplaceWith:=" ", Replace:=wdReplaceAll
    doc.Fields.Update
    ActiveWindow.View.ShowFieldCodes = False
    End Sub

    The ReplaceInFolder macro is the one to run. Make sure that you modify the constant strFolder to point to the correct folder.

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

    Re: Macro to remove ' from INCLUDEPICTURE fields (MS Word 2003, SP2)

    Hans,

    Thanks once again. Your macro works very well.

    One more question. Do you know if there is an existing macro that will point to a folder full of word documents and generate a list of word documents that contain "tracked changes". There are a few documents that contain tracked changes that I need to fix because this Macro will stop on them every time.

    Regards,

    -J

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

    Re: Macro to remove ' from INCLUDEPICTURE fields (MS Word 2003, SP2)

    Hello Hans,

    I spoke too soon. It looked like the Macro ran, but I am still seeing (percentage 20) code in my INCLUDEPICTURE field codes.

    I have attached the Macro (screen shot). Did I forget something in that code?

    Thanks,

    J
    Attached Images Attached Images

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

    Re: Macro to remove ' from INCLUDEPICTURE fields (MS Word 2003, SP2)

    Hello Hans,

    I played around the macro code and I think I have it appears to be working now (see screen shot).

    Thanks,

    Jim
    Attached Images Attached Images

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

    Re: Macro to remove ' from INCLUDEPICTURE fields (MS Word 2003, SP2)

    I don't know where you got the & # 37 ; 20 (without spaces) from, it's not in my post. Did you get it from the e-mail notification?

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

    Re: Macro to remove ' from INCLUDEPICTURE fields (MS Word 2003, SP2)

    Hello Hans and all -

    I have a Macro that will remove the percentage twenty code that Micosoft inserts when it sees a space between a graphic file name. All of my graphic files are linked to file in my MS Word 2003 documents. The Macro works for .DOC file formats, but now I need it to work for RTF. Can someone take a look at the attached screen shot and tell me why it doesn't work? Do I substitute out DOC anywhere it is found for RTF or not? I am probably missing something simple in the attached screenshot.

    For Andrew: Andrew, I think a while back you were interested in hearing about how to resolve the broken cross references when bringing a MS Word (.doc) file into FrameMaker. Well, the answer is simple after all. Simply save the (.doc file) to a (.rtf) format and you are all set. I had abandoned the RTF format originally when the percentage twenty code was messing up my imported graphics, but never went back to RTF after the imported graphic fix was found (via the macro). Now I do not need to focus on saving MS Word documents as XML files and running a XML transform to lift out all the junk code. I simply have to save my Docs as RTFs. Still, I will need to look at XML transforms down the road and there may be something valuable there in taking a MS Word document, saving to XML and filtering out the junk code.

    Thanks to all for you support over the last few months. It is very much appreciated.

    Regards,

    Jim
    Attached Images Attached Images

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

    Re: Macro to remove ' from INCLUDEPICTURE fields (MS Word 2003, SP2)

    Didn't you read the instruction in the green line?
    <hr>' Modify as needed, but keep the trailing backslash<hr>
    There is no backslash at the end of your path. It should be
    <code>
    Const strPath = "C:Temp8"</code>

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

    Re: Macro to remove ' from INCLUDEPICTURE fields (MS Word 2003, SP2)

    Hello Hans,

    Sorry about that. It is the little things in life that can make a big difference (hiding in plain sight as they say :-). Okay, I added the trailing backslash.
    And, I figured out that the *.RTF is only needed one one line of code, since those DOC commands are not tied to the ".doc" file extension.

    Anyway, it is working now.

    Thanks again for your time.

    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
  •