Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Conditional Compilation

Status
Not open for further replies.

jshulman

MIS
Oct 25, 2002
4
US
I need to use Conditional Compilation because I have an excel sheet that I need to use in 97 and 2000. I need to turn off an option that is only valid in Excel 2000 when I run Excel 2000.

I have tried various methods and I keep getting hung up on the fact that I can't get the Application Version when the code actually compiles.

The code I am using is:
#If appVer = 1 Then
cht.Activate
ActiveChart.HasPivotFields = False
#End If
End If

But when I set up my #Const AppVer = 1 it really needs to know the Application Version which it doesn't know until the code is actually executed.

Any help would be greatly appreciated.

Thanks in advance

jshulman
 
Why do you need to use conditional compile, rather than just conditional statements at runtime? If it's a matter of Excel throwing compile errors, you could put your version-dependent code in a separate sub (will only be compiled when it's actually called).
Rob
[flowerface]
 
Well, because I was getting a compile error when I compiled the program and when I ran it. However, your tip of putting that part of it into a separate subroutine, did the trick. Although, I would rather that I not get a compile error when I compile the program in 97 - it got me past the run time problem - so thanks.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top