none
Is there any way to prevent the themedata and datastore elements from being inserted in a RTF file in Word 2007? RRS feed

  • Question

  • When saving as a RTF in Word 2007 the file contains themedata and datastore elements which bloat the RTF. Is there any way to prevent these elements from being inserted in the RTF file in Word 2007?

    Wednesday, May 18, 2011 11:51 AM

Answers

  • Hi Steve

    No, the converter works the way it works and there are no "options" to guide this. The idea behind RTF is that it can reproduce the Word document with complete fidelity...


    Cindy Meister, VSTO/Word MVP
    • Marked as answer by Steve Childs Thursday, May 19, 2011 11:27 AM
    Wednesday, May 18, 2011 4:42 PM
    Moderator

All replies

  • Hi Steve

    No, the converter works the way it works and there are no "options" to guide this. The idea behind RTF is that it can reproduce the Word document with complete fidelity...


    Cindy Meister, VSTO/Word MVP
    • Marked as answer by Steve Childs Thursday, May 19, 2011 11:27 AM
    Wednesday, May 18, 2011 4:42 PM
    Moderator
  • Thanks for the response Cindy,

    I thought this would probably be the case.

    Thanks

    Steve

    Thursday, May 19, 2011 11:29 AM
  • Hi Steve

    What you could do, if you didn't mind the work, is to transform the Word 2007 OpenXML to the RTF you want to have. You might even find 3rd party tools for this. APOSE, for example, has some conversion products that can be licensed, and there may be others.


    Cindy Meister, VSTO/Word MVP
    Thursday, May 19, 2011 1:20 PM
    Moderator
  • I suppose it would not be too hard to save the file, then remove these elements via a fairly simple programmed find/replace, because they appear to be relatively easy to find. I'm sure someone will correct my wildcard expressions, but perhaps start with something like...

    Sub saveShorterRTF()

    Const strLongRTF = "c:\a\longrtf.rtf"

    Const strShortRTF = "c:\a\shortrtf.rtf"

    Dim objDocument As Word.Document

    ActiveDocument.SaveAs strLongRTF, WdSaveFormat.wdFormatRTF

    ActiveDocument.Close savechanges:=False

    Set objDocument = Word.Documents.Open(FileName:=strLongRTF, Format:=WdOpenFormat.wdOpenFormatText)

    With objDocument.Content.Find

      .ClearFormatting

      .Replacement.ClearFormatting

      ' we are looking for {\*\datastore<a chunk of non-} binary>}

      .Text = "\{\\\*\\themedata*\}"

      .Replacement.Text = ""

      .Forward = True

      .Wrap = wdFindStop

      .Format = False

      .MatchCase = False

      .MatchWholeWord = False

      .MatchWildcards = True

      .Execute Replace:=wdReplaceAll

    End With

    With objDocument.Content.Find

      .ClearFormatting

      .Replacement.ClearFormatting

      ' we are looking for {\*\datastore<a chunk of non-} binary>}

      .Text = "\{\\\*\\datastore[!\}]@\}"

      .Replacement.Text = ""

      .Forward = True

      .Wrap = wdFindStop

      .Format = False

      .MatchCase = False

      .MatchWholeWord = False

      .MatchWildcards = True

      .Execute Replace:=wdReplaceAll

    End With

    objDocument.SaveAs strShortRTF, WdSaveFormat.wdFormatText

    objDocument.Close savechanges:=False

    End Sub


    Peter Jamieson
    Thursday, May 19, 2011 3:50 PM
  • Open the document in Wordpad and resave it as RTF.
    Monday, August 22, 2016 11:21 AM
  • Open the document in Wordpad and resave it as RTF.

    A process that can be automated. See: https://social.msdn.microsoft.com/Forums/office/en-US/e41e944e-785a-43ce-8963-c76de1632726/reduce-rtf-file-size?forum=word

    Cheers
    Paul Edstein
    [MS MVP - Word]

    Monday, August 22, 2016 12:48 PM