• Comparing templates VBA code (Word97/SR2 et al.)

    Home » Forums » AskWoody support » Productivity software by function » Visual Basic for Applications » Comparing templates VBA code (Word97/SR2 et al.)

    Author
    Topic
    #384427

    I need a utility to compare two Word termplates (but it may as well compare any two projects from the same breed, i.e. compare two Excel sheets/templates/addins etc).

    Here I am with several versions of, say, Utils.dot, all within a few days of each other, and I’d like to know where they differ. I know that there will be some grunt work, but a utility that highlights at least

    1) differences in module names (“TEMPLATEA has a module ‘NEW’, and TEMPLATEB doesn’t have this module”).

    2) differences in module code (“module UT of TEMPLATEA was identical to module UT of TEMPLATEB until I reached THIS line of source”).

    3) options switch to disregard comment lines (OK, I make heavy use of Payne Consulting’s EXCELLENT VBA code cleaner).

    I could develop it by cannibalising an existing VBA code utility, soch as Procedure Stripper, or Procedure Clipper, but I’d rather not do the work.

    Viewing 1 reply thread
    Author
    Replies
    • #659441

      Why don’t you just use Visual Source Safe, Chris, and store your code projects there. You can compare between any two objects in VSS and even between versions of the same object, and it allows you to share code and objects between projects.

      • #660189

        Charlotte,

        I agree about the value of VSS, but have never been able to get it to compare versions of Word .dot files (which in our case contain .bas and .frm modules).
        If I view Versions, select two versions and then click on Diff, eventually I get a message saying “Binary files differ”.

        Have never tried it, but wonder if you would need to check say the modules’ .bas files individually, in order to get VSS to do a compare. Unfortunately that doesn’t jibe with how we use VSS with Word .dots, which is just to check in the .dot as a whole, rather than as individual pieces.

        Gary

        • #660211

          I haven’t really tried VSS with Word templates, so I can’t say. You can add a Word project to VSS and it goes in as a class which contains the objects in the project but not, apparently any templates. You can add a template project to VSS, but I don’t know how well it would work. If there are multiple versions in the history, it should allow you to compare them.

    • #661548

      If your goal is to compare the macro code, then save the code from each template to .BAS files and compare those. You can use the FC.EXE command supplied with windows (it is a carry over from DOS days) if you don’t have anything better. Or you could use Word’s document compare on the .BAS files.

      Neither has the advanced options you’d like, but there are tools that do. The GNU diff command does have the options that you’d like. There is a version that runs under Windows (or DOS). The latest version can handle long file names but the earlier versions won’t.

      • #661567

        > If your goal is to compare the macro code,

        Thanks, but no. I really want to get a comprehensive report on the entire project, so comparing macro code (alone) won’t do it. Maybe THIS project has a module “Module4” that is lacking in the other module.

        And since it IS VBA code, I’d always want an option that allowed me to ignore comments, as defined in Payne Consulting’s Code Cleaner.

    Viewing 1 reply thread
    Reply To: Comparing templates VBA code (Word97/SR2 et al.)

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

    Your information: