Consulting

Results 1 to 8 of 8

Thread: Version clash

  1. #1
    VBAX Regular
    Joined
    Feb 2007
    Location
    Southampton, England
    Posts
    14
    Location

    Question Version clash

    I have written a macro which has been distributed throughout my company for different units to use.

    It contains the following instruction:

    ActiveSheet.Protect PassWord:=PassWd, AllowFormattingColumns:=True, AllowFormattingCells:=True

    Which works fine for the majority. However, a couple of units have older versions of Excel, where AllowFormattingColumns and AllowFormattingCells are not part of the Protect method and therefore throws up an error.
    Is there another way to protect sheets while still allowing format columns and cells in the older versions of Excel or should I just tell them to make business cases for newer versions?

    Thanks in advance for your
    Diana

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Just use

    [vba]

    ActiveSheet.Protect PassWord:=PassWd
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    VBAX Regular
    Joined
    Feb 2007
    Location
    Southampton, England
    Posts
    14
    Location
    That won't allow formatting of columns and cells now which is my problem.
    Diana

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [vba]

    if Val(Application.Version) >= 10 Then
    ActiveSheet.Protect PassWord:=PassWd, AllowFormattingColumns:=True, AllowFormattingCells:=True
    Else
    ActiveSheet.Protect PassWord:=PassWd
    Endif
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  5. #5
    VBAX Regular
    Joined
    Feb 2007
    Location
    Southampton, England
    Posts
    14
    Location
    No, I'm not sure I'm getting you to understand the problem.

    What I want to know is, for the older versions of Excel, is there something I can do which will allow formatting of cells on a protected sheet. Just getting them protected I'm okay with - it's the formatting which is an issue.
    Diana

  6. #6
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    No, because as YOU pointed out, it isn't supported in previous versions.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  7. #7
    VBAX Master
    Joined
    Jun 2007
    Location
    East Sussex
    Posts
    1,110
    Location
    If you can't get them an upgrade, you'll probably have to add your own functionality to format the columns. If you use the userinterfaceonly:=true argument when protecting the sheet, your code won't even need to unprotect the sheets to format them.
    HTH
    Rory

  8. #8
    VBAX Regular
    Joined
    Feb 2007
    Location
    Southampton, England
    Posts
    14
    Location
    Thanks Rory, I'll see what I can do with that.
    Diana

Posting Permissions

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