Results 1 to 2 of 2
  1. #1
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Sydney, Australia, New South Wales, Australia
    Posts
    251
    Thanks
    0
    Thanked 4 Times in 4 Posts

    Portable code 2000 to 2007 (Word 2000/Word 2007)

    Hi
    I've got some Word VBA code that I want to run on W2000 and on W2007. In particular, I want to temporarily turn off the annoying 'tracked changes warning' that only appears on W2007.
    I've got this code, which works well on W2007.
    But it won't run on W2000, because the W2007-specific code causes a compile error under W2000. Even though the code won't be reached for the 'wrong' version of Word.
    Does anyone know how I can have conditional compilation under VBA? (I'm thinking C's #ifdef kind of thing)
    Or an alternative to what I'm trying to do here?
    Thanks for any insights.
    Peter

    <pre>If Application.Version >= 12 Then
    'For Word 2007, temporarily turn off silly 'contains tracked changes' warning
    Dim currentSetting
    currentSetting = Word.Options.WarnBeforeSavingPrintingSendingMarkup
    Word.Options.WarnBeforeSavingPrintingSendingMarkup = False
    oWordDocument.SaveAs sPathAndFileName
    Word.Options.WarnBeforeSavingPrintingSendingMarkup = currentSetting
    Else
    oWordDocument.SaveAs sPathAndFileName
    End If
    </pre>


  2. #2
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Sydney, Australia, New South Wales, Australia
    Posts
    251
    Thanks
    0
    Thanked 4 Times in 4 Posts

    SOLVED

    SOLVED:
    I've found it, so have posted it in case anyone else ever needs it.
    It's not quite automatic, but means I only have to change one line between versions.
    Peter

    <pre>#Const APP_VERSION = 9
    ...
    #If APP_VERSION >= 12 Then
    'For Word 2007, temporarily turn off silly 'contains tracked changes' warning
    Dim currentSetting
    currentSetting = Word.Options.WarnBeforeSavingPrintingSendingMarkup
    Word.Options.WarnBeforeSavingPrintingSendingMarkup = False
    oWordDocument.SaveAs sPathAndFileName
    Word.Options.WarnBeforeSavingPrintingSendingMarkup = currentSetting
    #Else
    oWordDocument.SaveAs sPathAndFileName
    #End If
    </pre>


Posting Permissions

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