Results 1 to 6 of 6
  1. #1
    5 Star Lounger
    Join Date
    Feb 2001
    Location
    Youngstown, Ohio, USA
    Posts
    705
    Thanks
    1
    Thanked 0 Times in 0 Posts

    SaveAs giving different file sizes (2000 SP3)

    I use a VBA-enhanced Word document to convert a plain text file without page breaks into a Word document with page breaks. Formerly, the VBA code I use would only make one copy of the converted file, but to gain a little bit of archival security I duplicated the SaveAs code to save an extra copy with a date-stamped filename. The code works but the two 'identical' files are completely different sizes. The date-stamped copy is 153KB versus the plain-named copy's 94KB. The subsequent code does nothing to either modify or save the file.

    I'm slightly confused -- I would expect, and would much rather have, absolutely identical files. Is the second (DOC to DOC) file getting compressed, whereas the first (TXT to DOC) has some bloat left in it from the conversion?

    <pre>Documents.Open FileName:="DOLLY.TXT", ConfirmConversions:=False, _
    ReadOnly:=True, AddToRecentFiles:=False, PasswordDocument:="", _
    PasswordTemplate:="", Revert:=False, WritePasswordDocument:="", _
    WritePasswordTemplate:="", Format:=wdOpenFormatAuto
    With Selection.Find
    .ClearFormatting
    .Replacement.ClearFormatting
    .Text = "LOCATION"
    .Replacement.Text = "^mLOCATION"
    .Forward = True
    .Wrap = wdFindContinue
    .Execute Replace:=wdReplaceAll
    End With
    Selection.Delete Unit:=wdCharacter, Count:=1
    ChangeFileOpenDirectory "C:ApplicationsDolly"
    ActiveDocument.SaveAs FileName:="DOLLY" & " " & Format(Now(), "YYMMDD") & ".DOC", _
    FileFormat:=wdFormatDocument, LockComments:=False, Password:="", _
    AddToRecentFiles:=True, WritePassword:="", ReadOnlyRecommended:=False, _
    EmbedTrueTypeFonts:=False, SaveNativePictureFormat:=False, SaveFormsData:=False, _
    SaveAsAOCELetter:=False
    ActiveDocument.SaveAs FileName:="DOLLY.DOC", _
    FileFormat:=wdFormatDocument, LockComments:=False, Password:="", _
    AddToRecentFiles:=True, WritePassword:="", ReadOnlyRecommended:=False, _
    EmbedTrueTypeFonts:=False, SaveNativePictureFormat:=False, SaveFormsData:=False, _
    SaveAsAOCELetter:=False
    Application.Documents("DollyConvert.doc").Close
    Application.ScreenUpdating = True
    </pre>

    Attached Images Attached Images

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

    Re: SaveAs giving different file sizes (2000 SP3)

    When I tried your code, it produced to .doc files of exactly the same size. I don't know why it's different when you try it. However, you could save the document once, then copy the saved file:

    ...
    ...
    Selection.Delete Unit:=wdCharacter, Count:=1
    ActiveDocument.SaveAs FileName:="C:ApplicationsDollyDolly.doc"
    ActiveDocument.Close
    FileCopy "C:ApplicationsDollyDolly.doc", ""C:ApplicationsDollyDolly" & Format(Now(), "yymmdd") & ".doc"

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

    Re: SaveAs giving different file sizes (2000 SP3)

    The first thing I would check is the Allow Fast Saves option under Tools > Options > Save. This should be turned off.
    Andrew Lockton, Chrysalis Design, Melbourne Australia

  4. #4
    5 Star Lounger
    Join Date
    Feb 2001
    Location
    Youngstown, Ohio, USA
    Posts
    705
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: SaveAs giving different file sizes (2000 SP3)

    That little trick should do the job just right, thanks. I was previously unaware of the FileCopy command but I'm sure I'll find lots of other uses for it now. To use this fix I'll have to save, close, FileCopy, and then open again but it should be an easy bit of code to whip together.

  5. #5
    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: SaveAs giving different file sizes (2000 SP3)

    Maybe it's metadata, as the second save is smaller than the first. Could you zip up a pair of those documents for examination with a metadata scanner?

  6. #6
    5 Star Lounger
    Join Date
    Feb 2001
    Location
    Youngstown, Ohio, USA
    Posts
    705
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: SaveAs giving different file sizes (2000 SP3)

    The FileCopy trick from Hans worked and I'm now getting identical files from the code, so my main concern is taken care of. The bloat is unquestionably metadata, but I'm not really concerned about squeezing it out since the file sizes are still small enough to email conveniently, even with the bloat.

Posting Permissions

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