Consulting

Results 1 to 3 of 3

Thread: Solved: Only run this command if Excel version is above 2003

  1. #1
    VBAX Expert
    Joined
    Sep 2010
    Posts
    604
    Location

    Solved: Only run this command if Excel version is above 2003

    I have this code in an .xls workbook designed for use primarily in 2007, in the selection change event (it works very well)

    I've been using On Error Resume Next to avoid an error if the workbook is run in 2003,
    but prefer to make changes to stay away from that.
    ** Checking the Excel version as shown below seems to work.
    Would like opinions on whether or not this is the cleanest way to go.
    [vba]
    If Application.Version >= "12.0" Then
    If Not Application.CommandBars.Item("Ribbon").Height > 100 Then
    'Ribbon is Minimized
    'do nothing
    ' I don't know why but using If Not and Else is working more consitantly with send keys .
    Else
    Application.SendKeys ("^{F1}")
    '~~> Minimize Ribbon
    End If
    End If
    [/vba]
    Last edited by frank_m; 10-19-2011 at 01:47 AM. Reason: rephrased the first sentence to note that the routine has been working well

  2. #2
    VBAX Master Aflatoon's Avatar
    Joined
    Sep 2009
    Location
    UK
    Posts
    1,598
    Location
    I would use:
    [vba]If Val(Application.Version) >= 12 Then[/vba]
    Be as you wish to seem

  3. #3
    VBAX Expert
    Joined
    Sep 2010
    Posts
    604
    Location
    Thanks Aflatoon

Posting Permissions

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