Results 1 to 6 of 6
  1. #1
    New Lounger
    Join Date
    Feb 2002
    Location
    Sydney, Australia
    Posts
    24
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hello,

    I maintain a Word template that has some macros in modules. At each milestone, I use File->Export File to export each module to a text file, then I check the text files into a Mercurial repository, using TortoiseHg.

    Sometimes I find that the export process has changed the case of variables, such as from MAIN to Main, or nl$ to NL$. The modules still work, because the changes have happened consistently, but the version control system notices the difference and flags each module as needing to be updated in the repository. I then have to check all the changes, in case I have changed something inadvertently, only to realise that "the system" is at fault again :-(

    Here's what the differences look like:
    -Dim sMsg$, NL$ ' string buffer for Message Box text.
    -NL$ = Chr(10) ' new line, 'hard return' for WinWord
    +Dim sMsg$, nl$ ' string buffer for Message Box text.
    +nl$ = Chr(10) ' new line, 'hard return' for WinWord

    Is this documented behaviour for the Export File process? Is there a way I can turn it off?

    I am using Word 2003, SP 3 on XP SP 3

    Looking forward to your help,

    Jim

  2. Subscribe to our Windows Secrets Newsletter - It's Free!

    Get our unique weekly Newsletter with tips and techniques, how to's and critical updates on Windows 7, Windows 8, Windows XP, Firefox, Internet Explorer, Google, etc. Join our 480,000 subscribers!

    Excel 2013: The Missing Manual

    + Get this BONUS — free!

    Get the most of Excel! Learn about new features, basics of creating a new spreadsheet and using the infamous Ribbon in the first chapter of Excel 2013: The Missing Manual - Subscribe and download Chapter 1 for free!

  3. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts
    Sounds like a bug! I can't recall it being mentioned here before, but that may be because most people do not do a text compare against other versions. (And of course VBA is case insensitive, so it doesn't break the code.) Perhaps there's something about this on Microsoft's MSDN forums??

  4. #3
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 28 Times in 27 Posts
    Jim,

    Is it possible that these case changes are being introduced somewhere in the process, by the Mercurial/Tortoise tools? - I've never worked with either, so don't have any insight into those.
    A lot of VBA developers use code cleaner utilities that automate the export/re-import of code files - these work programatically with the VBE's own export/import tools - and I've never experienced nor heard of case changes like you're seeing. (Even without a version control system to do a comparison, major changes to case throughout a code project would be instantly noticeable.)

    I wonder if it might be worth, as a test, manually exporting/importing copies of the code modules in a separate backup copy of your template, at the same time you do the Mercurial/Tortoise backup, and compare the results of the two processes after a while.

    Last question is: for maintaining some code modules in a single Word template, isn't backing the code files up to a code repository somewhat overkill? Couldn't you just save incremental copies of your template to some kind of removable or online media?

    When I worked in-house as a member of a team, we backed everything up to VSS, but since I've been doing this stuff freelance, I find incremental copies of my templates (saved to other media) to be plenty of backup. I also put lots of dated inline comments in the code, to annotate anything but minor changes. What benefits (besides the compare) do you get from the Mercurial repository?

    Gary

  5. #4
    New Lounger
    Join Date
    Feb 2002
    Location
    Sydney, Australia
    Posts
    24
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks, jscher, I did post a question there also, and have just found a suggestion to use VBA Word Cleaner. No acknowledgement that it might be a bug, though.
    I'll try the cleaner. The link to the suggestion is http://social.msdn.microsoft.com/For...9-a9a6a25d8ec1

  6. #5
    New Lounger
    Join Date
    Feb 2002
    Location
    Sydney, Australia
    Posts
    24
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks for the reply, Gary,

    You asked if TortoiseHg or Mercurial could be making the changes. No, it's the export from the VBA editor that is doing it. I can demonstrate that by looking in my own folder tree at the version 1.14 files, that I saved before and then checked into the version control system, and comparing them by eyeball with the ones that I have just exported from the VBA editor. The cases of the variable names are different, as I described.

    You suggest exporting from an older version of the template -- I'll try that.

    You ask if using a version control system is overkill, and suggest keeping backup copies of the template. I do that already, because I do an incremental backup every day to external media, so I can get the template back from any day's version whenever I like. But the reason I like to use the version control system is that the template is like compiled code, in that it is hidden within the template, whereas the exported text files are like the source code, and I can see the change history much more easily in the exported text files. With Mercurial, I can very quickly answer the question "What changes have happened in this module in the last 5 versions?" Without that, I would have to get back the 4 older versions of the template, being careful to choose the right dates, open each one and export the module to a text file, then use a diff program to display the differences. The version control system makes that much easier, and TortoiseHg is a very convenient front end to Mercurial, giving options in the context-sensitive menu in Windows Explorer.

    Jim

  7. #6
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 28 Times in 27 Posts
    Jim,

    You make a good case for using a version control system - I may have to rethink my processes!

    In case it's helpful, here's a link to Rob Bovey's VBA Code Cleaner utility.

    If you find a solution to the change case problem, please post it here.

    Gary

Posting Permissions

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