Results 1 to 4 of 4
  1. #1
    New Lounger
    Join Date
    Jan 2003
    Location
    USA
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Running Blocks of Code Conditioned on Word Version (Word 2000 / 2003)

    I have a word document that acts as a template and is copied and modified. The document contains comments. Some users are on Word 2003 and some on 2000. The Word 2003 users were getting a security dialog when saving or printing so this code was put in:

    blnOldState = Application.Options.WarnBeforeSavingPrintingSendin gMarkup
    Application.Options.WarnBeforeSavingPrintingSendin gMarkup = False
    ...
    Application.Options.WarnBeforeSavingPrintingSendin gMarkup = blnOldState

    Now the Word 2000 users halt because this setting doesn't exist in 2000.

    Is there any way to condition code to run according to the version running? Or is there another way around this? I tried to code around it by using the version but it seems the code is validated before being run and halts on the new setting whether the code will be executed or not.

    Thanks in advance...I posted a similar question earlier but I hope this better explains my dilemma.

    - Steve

  2. #2
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Running Blocks of Code Conditioned on Word Version (Word 2000 / 2003)

    I think you can do this by putting the code that should only run on the later version in a completely separate module. You then check the Word version and call the code in that module if it is needed. If you don't call any code in the module then it won't give you errors.

    StuartR

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

    Re: Running Blocks of Code Conditioned on Word Version (Word 2000 / 2003)

    VBA only compiles modules when needed. So you can put all code that is Word 2003 specific in a separate module. In your main module, test the version, and only call the code in the other module if the version is right.

    Sub Something()
    If Val(Application.Version) > 9 Then
    Call OtherMacro
    End If
    End Sub

    The macro OtherMacro *must* be in another module than Something. It can use WarnBeforeSavingPrintingSendingMarkup.

  4. #4
    New Lounger
    Join Date
    Jan 2003
    Location
    USA
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Running Blocks of Code Conditioned on Word Version (Word 2000 / 2003)

    Thanks to both Hans and Stuart for shedding some light on the subject.

Posting Permissions

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