• SaveAs giving different file sizes (2000 SP3)

    Home » Forums » AskWoody support » Productivity software by function » MS Word and word processing help » SaveAs giving different file sizes (2000 SP3)

    Author
    Topic
    #433434

    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?

    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
    
    Viewing 2 reply threads
    Author
    Replies
    • #1019464

      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”

      • #1019478

        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.

    • #1019476

      The first thing I would check is the Allow Fast Saves option under Tools > Options > Save. This should be turned off.

    • #1019490

      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?

      • #1020027

        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.

    Viewing 2 reply threads
    Reply To: SaveAs giving different file sizes (2000 SP3)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: