+ Reply to Thread
Results 1 to 5 of 5

#If #else #endif

  1. #1
    Carl-Rainer Zeiss
    Guest

    #If #else #endif

    Hello,

    I have to protect a worksheet. The kind of protection must depend on the
    excel-version, because I have several customers with different versions of
    Office.
    First I tried with if-else-endif, but got a runtime error with O 2000,
    because the "AllowFormatting" is not available in O 2000.
    Then I tried with the #if-#else-#endif condition, but this doesn't work.

    I tried:

    Ver = CCur(Application.Version)
    #If Ver >= 10 Then
    pwTab.Protect UserInterfaceOnly:=True, _
    Password:=Pw, _
    AllowFormattingColumns:=True, _
    AllowFormattingCells:=True
    #Else
    pwTab.Protect UserInterfaceOnly:=True, _
    Password:=Pw
    #End If

    Then I read the help and it says I have to use a special constant #const,
    but how should I get the "Application.Version" into a constant?

    ________________________________________
    Carl-Rainer Zeiss
    EDV System-Beratungen
    Lohrgasse 11, D-60389 Frankfurt
    Tel: +49 69 90478774
    Fax: +49 1212 66666111222
    Mail: [email protected]



  2. #2
    Norman Jones
    Guest

    Re: #If #else #endif

    Hi Carl-Rainer,

    Your conditional compilation code works without problem for me.

    What error do you encounter?


    ---
    Regards,
    Norman


    "Carl-Rainer Zeiss" <[email protected]> wrote in message
    news:OT%[email protected]...
    > Hello,
    >
    > I have to protect a worksheet. The kind of protection must depend on the
    > excel-version, because I have several customers with different versions of
    > Office.
    > First I tried with if-else-endif, but got a runtime error with O 2000,
    > because the "AllowFormatting" is not available in O 2000.
    > Then I tried with the #if-#else-#endif condition, but this doesn't work.
    >
    > I tried:
    >
    > Ver = CCur(Application.Version)
    > #If Ver >= 10 Then
    > pwTab.Protect UserInterfaceOnly:=True, _
    > Password:=Pw, _
    > AllowFormattingColumns:=True, _
    > AllowFormattingCells:=True
    > #Else
    > pwTab.Protect UserInterfaceOnly:=True, _
    > Password:=Pw
    > #End If
    >
    > Then I read the help and it says I have to use a special constant #const,
    > but how should I get the "Application.Version" into a constant?
    >
    > ________________________________________
    > Carl-Rainer Zeiss
    > EDV System-Beratungen
    > Lohrgasse 11, D-60389 Frankfurt
    > Tel: +49 69 90478774
    > Fax: +49 1212 66666111222
    > Mail: [email protected]
    >




  3. #3
    Tom Ogilvy
    Guest

    Re: #If #else #endif

    To the best of my knowledge, compiler constants can't be defined on variable
    information.

    There are no built in compiler constants that will distinguish between
    xl2000, xl2002 and xl2003

    --
    Regards,
    Tom Ogilvy

    "Carl-Rainer Zeiss" <[email protected]> wrote in message
    news:OT%[email protected]...
    > Hello,
    >
    > I have to protect a worksheet. The kind of protection must depend on the
    > excel-version, because I have several customers with different versions of
    > Office.
    > First I tried with if-else-endif, but got a runtime error with O 2000,
    > because the "AllowFormatting" is not available in O 2000.
    > Then I tried with the #if-#else-#endif condition, but this doesn't work.
    >
    > I tried:
    >
    > Ver = CCur(Application.Version)
    > #If Ver >= 10 Then
    > pwTab.Protect UserInterfaceOnly:=True, _
    > Password:=Pw, _
    > AllowFormattingColumns:=True, _
    > AllowFormattingCells:=True
    > #Else
    > pwTab.Protect UserInterfaceOnly:=True, _
    > Password:=Pw
    > #End If
    >
    > Then I read the help and it says I have to use a special constant #const,
    > but how should I get the "Application.Version" into a constant?
    >
    > ________________________________________
    > Carl-Rainer Zeiss
    > EDV System-Beratungen
    > Lohrgasse 11, D-60389 Frankfurt
    > Tel: +49 69 90478774
    > Fax: +49 1212 66666111222
    > Mail: [email protected]
    >
    >




  4. #4
    Carl-Rainer Zeiss
    Guest

    Re: #If #else #endif

    Hello,

    I am using O 2003
    Ver gets 110 (from "1.10")
    Problem is: the Code jumps directly to the #else-condition

    ________________________________________
    Carl-Rainer Zeiss
    EDV System-Beratungen
    Lohrgasse 11, D-60389 Frankfurt
    Tel: +49 69 90478774
    Fax: +49 1212 66666111222
    Mail: [email protected]


    "Norman Jones" <[email protected]> schrieb im Newsbeitrag
    news:[email protected]...
    > Hi Carl-Rainer,
    >
    > Your conditional compilation code works without problem for me.
    >
    > What error do you encounter?
    >
    >
    > ---
    > Regards,
    > Norman
    >
    >
    > "Carl-Rainer Zeiss" <[email protected]> wrote in message
    > news:OT%[email protected]...
    >> Hello,
    >>
    >> I have to protect a worksheet. The kind of protection must depend on the
    >> excel-version, because I have several customers with different versions
    >> of Office.
    >> First I tried with if-else-endif, but got a runtime error with O 2000,
    >> because the "AllowFormatting" is not available in O 2000.
    >> Then I tried with the #if-#else-#endif condition, but this doesn't work.
    >>
    >> I tried:
    >>
    >> Ver = CCur(Application.Version)
    >> #If Ver >= 10 Then
    >> pwTab.Protect UserInterfaceOnly:=True, _
    >> Password:=Pw, _
    >> AllowFormattingColumns:=True, _
    >> AllowFormattingCells:=True
    >> #Else
    >> pwTab.Protect UserInterfaceOnly:=True, _
    >> Password:=Pw
    >> #End If
    >>
    >> Then I read the help and it says I have to use a special constant #const,
    >> but how should I get the "Application.Version" into a constant?
    >>
    >> ________________________________________
    >> Carl-Rainer Zeiss
    >> EDV System-Beratungen
    >> Lohrgasse 11, D-60389 Frankfurt
    >> Tel: +49 69 90478774
    >> Fax: +49 1212 66666111222
    >> Mail: [email protected]
    >>

    >
    >




  5. #5
    Bob Phillips
    Guest

    Re: #If #else #endif

    Try

    Ver = Val(Application.Version)

    --
    HTH

    Bob Phillips

    (remove nothere from email address if mailing direct)

    "Carl-Rainer Zeiss" <[email protected]> wrote in message
    news:OT%[email protected]...
    > Hello,
    >
    > I have to protect a worksheet. The kind of protection must depend on the
    > excel-version, because I have several customers with different versions of
    > Office.
    > First I tried with if-else-endif, but got a runtime error with O 2000,
    > because the "AllowFormatting" is not available in O 2000.
    > Then I tried with the #if-#else-#endif condition, but this doesn't work.
    >
    > I tried:
    >
    > Ver = CCur(Application.Version)
    > #If Ver >= 10 Then
    > pwTab.Protect UserInterfaceOnly:=True, _
    > Password:=Pw, _
    > AllowFormattingColumns:=True, _
    > AllowFormattingCells:=True
    > #Else
    > pwTab.Protect UserInterfaceOnly:=True, _
    > Password:=Pw
    > #End If
    >
    > Then I read the help and it says I have to use a special constant #const,
    > but how should I get the "Application.Version" into a constant?
    >
    > ________________________________________
    > Carl-Rainer Zeiss
    > EDV System-Beratungen
    > Lohrgasse 11, D-60389 Frankfurt
    > Tel: +49 69 90478774
    > Fax: +49 1212 66666111222
    > Mail: [email protected]
    >
    >




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1