Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
WK WK is offline
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Project - Forms Data Compilation John Leigh Excel Discussion (Misc queries) 0 September 25th 07 05:44 PM
Excel: Compilation error in Module 1. How can I find it? Tom Torda Excel Discussion (Misc queries) 1 January 13th 07 11:51 PM
Data compilation within a single workbook Robert Excel Worksheet Functions 0 March 13th 06 11:23 PM
Post Compilation Packaging StephenAccountant Setting up and Configuration of Excel 0 February 22nd 06 02:59 AM
summing up daily data in a monthly compilation mark_vi_ Excel Worksheet Functions 2 June 22nd 05 01:07 AM


All times are GMT +1. The time now is 09:25 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"