Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Conditional compilation
Hi,
I wrote an Excel programm under Excel 2000. Some parts are not running in Excel 97 because of some new used features Excel 2000 offers. To run the Excel programm in both versions -in Excel 97 with some reduced functions :( - I used the conditional compilation. So, in the project property I set the following statement "EXCEL2000 = 0" for the program that shall run with Excel 97. In the VBA code I used the conditional statements in the necessary code sections as follows #IF EXCEL2000=0 then .... #ELSE .... # END IF Everything works fine when I devoled all under Excel 2000. But when I use the programm in Excel 97 I get a runtime-error during the start of the Excel programm. When I translate the error message into English it is as follows : "You have to finish an #IF statement with #END IF". This I do !!!! The program shows the blue bar in the beginning of the second function of a module that I completey will only offer for Excel 2000 users (using the conditional IF-function mentioned above). What is rediclious to me, when I again compile the Excel VBA after the runtime-error appeared everything seems fine and I get no compile error. This is not very satisfying. Does anyone has an idea why Excel 97 behaves so and how I can prevent this error message. Thanks in advance, Winfried (800) |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Conditional compilation
Hi WK,
Use the structure below. You can compile it only on Excel 97, but you can run it in all Excel versions (97 to 2002). Sub Main() 'Here you can put all statements compatible with all Excel Version If Val(Application.Version) 8 Then #If VBA6 Then 'Here you can put all statements not compatible with Excel 97 If Val(Application.Version) 9 Then VBAExcel10 #End If End If End Sub Sub VBAExcel10() 'Here you can put all statements not compatible with Excel 97 and Excel 2000 End Sub -- HTH --- Orlando Magalhães Filho (So that you get best and rapid solution and all may benefit from the discussion, please reply within the newsgroup, not in email) "WK" escreveu na mensagem ... Hi, I wrote an Excel programm under Excel 2000. Some parts are not running in Excel 97 because of some new used features Excel 2000 offers. To run the Excel programm in both versions -in Excel 97 with some reduced functions :( - I used the conditional compilation. So, in the project property I set the following statement "EXCEL2000 = 0" for the program that shall run with Excel 97. In the VBA code I used the conditional statements in the necessary code sections as follows #IF EXCEL2000=0 then .... #ELSE .... # END IF Everything works fine when I devoled all under Excel 2000. But when I use the programm in Excel 97 I get a runtime-error during the start of the Excel programm. When I translate the error message into English it is as follows : "You have to finish an #IF statement with #END IF". This I do !!!! The program shows the blue bar in the beginning of the second function of a module that I completey will only offer for Excel 2000 users (using the conditional IF-function mentioned above). What is rediclious to me, when I again compile the Excel VBA after the runtime-error appeared everything seems fine and I get no compile error. This is not very satisfying. Does anyone has an idea why Excel 97 behaves so and how I can prevent this error message. Thanks in advance, Winfried (800) |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Project - Forms Data Compilation | Excel Discussion (Misc queries) | |||
Excel: Compilation error in Module 1. How can I find it? | Excel Discussion (Misc queries) | |||
Data compilation within a single workbook | Excel Worksheet Functions | |||
Post Compilation Packaging | Setting up and Configuration of Excel | |||
summing up daily data in a monthly compilation | Excel Worksheet Functions |