Results 1 to 3 of 3
  1. #1
    New Lounger
    Join Date
    Jun 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Macro to compare one word with multiple word files (1)

    Hi,
    Can any one help me in creating a macro to compare one document with multiple word documents and save it in a new folder or a new name.
    For exampleoriginaloriginal.doc and compare with D:edited1.doc, 2.doc, 3.doc.....etc and save in D:comparedcompared1.doc, compared2.doc, compared3.doc....

    Please help me in this regard

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

    Re: Macro to compare one word with multiple word files (1)

    Welcome to Woody's Lounge!

    You may be able to use the following macro as starting point:
    <code>
    Sub CompareAndSave()
    Const strCurDoc = "D:OriginalOriginal.doc"
    ' Keep the backslash after the paths
    Const strOldPath = "D:Edited"
    Const strNewPath = "D:Compared"
    Dim strFile As String
    Dim docCur As Document
    Dim docOld As Document
    Dim docNew As Document

    Set docCur = Documents.Open(FileName:=strCurDoc)

    strFile = Dir(strOldPath & "*.doc")
    Do While Not strFile = ""
    docCur.Merge FileName:=strOldPath & strFile, _
    MergeTarget:=wdMergeTargetNew, DetectFormatChanges:=True, _
    UseFormattingFrom:=wdFormattingFromPrompt, AddToRecentFiles:=False
    Set docNew = ActiveDocument
    docNew.SaveAs FileName:=strNewPath & strFile
    docNew.Close SaveChanges:=False
    strFile = Dir
    Loop
    End Sub
    </code>
    Modify the constants at the beginning as needed. You can add bells and whistles such as error handling, interactively selecting a document to process etc.

  3. #3
    New Lounger
    Join Date
    Jun 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Macro to compare one word with multiple word files (1)

    This worked perfect for me. Thanks for your time and help Hans

    Warm Regards,
    Manju P.

Posting Permissions

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