Conditional Statements

Using conditional directives #If ... then ... #else in the Compiled Workbook
xlCompiler uses VBA to create and manage Ribbon controls. So, you need to have at least base knowledge about VBA programming.
What is Conditonal Directive?
You can find official documentation from Microsoft on this page #If ... then ... #else directive.
In short this statement is similar to usual If ... then ... else ... end if statement. But it defines which block of code is compiled and which one is ignored. For example, you can put different portions of code for 32-bit and 64-bit platforms.
How Conditional Directive is used by xlCompiler?
Microsoft Excel doesn't allow to modify Ribbon at runtime. So, VBA Code used by xlCompiler to create Ribbon will not work in Excel. We need to separate code used by xlCompiler with conditional directive to prevent it from being compiled by Excel.
Below you can see example of such VBA macro:
#If XLC Then
Application.DisplayFormulaBar = False
Application.DisplayScrollBars = False
#End If
It hides Formula Bar and Scroll Bars is workbook is running in xlCompiler.
This method is used for all code relative to Ribbon. It works ONLY in the compiled version of the workbook. So, it is separated with #if XLC Then statement.
XLC is a symbol which is defined in the compiled application only. You can use it for your own purposes to implement different behavior between original Excel workbook and compiled Application.
Go to top